Home Download Buy Blog Forum Support

ST3: Threads of unloaded/reloaded plugins are still active

ST3: Threads of unloaded/reloaded plugins are still active

Postby schlamar on Fri Feb 22, 2013 10:20 am

Here is a simple test script:

Code: Select all
import time
import threading

def task():
    while True:
        print ('x')
        time.sleep(1)

threading.Thread(target=task).start()


Just save it in the packages folder. You will see as expected:

Code: Select all
reloading plugin User.test
x
x


After deleting the plugin it gets unloaded, however the thread is still active:

Code: Select all
unloading plugin User.test
x
x
schlamar
 
Posts: 106
Joined: Tue Feb 19, 2013 2:11 pm

Re: ST3: Threads of unloaded/reloaded plugins are still active

Postby jps on Fri Feb 22, 2013 11:35 am

This is by design, it's a plugins responsibility to stop its own threads.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: ST3: Threads of unloaded/reloaded plugins are still active

Postby schlamar on Fri Feb 22, 2013 11:46 am

jps wrote:This is by design, it's a plugins responsibility to stop its own threads.

Ok, but this will require a `before_plugin_unload` signal or something like this if you want to use concepts like thread pool or evented loop.
schlamar
 
Posts: 106
Joined: Tue Feb 19, 2013 2:11 pm

Re: ST3: Threads of unloaded/reloaded plugins are still active

Postby jps on Fri Feb 22, 2013 11:50 am

Plugin modules may define a plugin_unloaded() method that will be called at the required time.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 14 guests