Skip to content

Conversation

@CookStar
Copy link
Contributor

@CookStar CookStar commented Dec 2, 2020

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
Copy link
Member

Ayuto commented Dec 11, 2020

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