Sublime Forum

ST3: Threads of unloaded/reloaded plugins are still active

#1

Here is a simple test script:

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:

reloading plugin User.test x x

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

unloading plugin User.test x x

0 Likes

#2

This is by design, it’s a plugins responsibility to stop its own threads.

0 Likes

#3

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.

0 Likes

#4

Plugin modules may define a plugin_unloaded() method that will be called at the required time.

0 Likes