Skip to content

Changed AutoUnload to be able to manage objects generated from custom packages.#365

Merged
Ayuto merged 1 commit into
Source-Python-Dev-Team:masterfrom
CookStar:auto_unload
Dec 11, 2020
Merged

Changed AutoUnload to be able to manage objects generated from custom packages.#365
Ayuto merged 1 commit into
Source-Python-Dev-Team:masterfrom
CookStar:auto_unload

Conversation

@CookStar

@CookStar CookStar commented Dec 2, 2020

Copy link
Copy Markdown
Contributor

This ensures the code that generates objects that expect unload in the custom packages works correctly.

# addons/source-python/packages/custom/test/__init__.py

# Source.Python Imports
#   Core
from core import AutoUnload

class Test(AutoUnload):
    def __init__(self):
        print("init Test")
    def _unload_instance(self):
        print("unloaded Test")

def test():
    return Test()
# addons/source-python/plugins/test_plugin/test_plugin.py

from test import Test
from test import test

Test()
test()

Output:

sp plugin load test_plugin
[SP] Loading plugin 'test_plugin'...
init Test
init Test
[SP] Successfully loaded plugin 'test_plugin'.
sp plugin unload test_plugin
[SP] Unloading plugin 'test_plugin'...
unloaded Test
unloaded Test
[SP] Successfully unloaded plugin 'test_plugin'.

@Ayuto

Ayuto commented Dec 11, 2020

Copy link
Copy Markdown
Member

Thank you, that works very well!

@Ayuto Ayuto merged commit 6722989 into Source-Python-Dev-Team:master Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants