Extension of threading.Thread adding terminate method using Win32 API on Python
Just replace your use of threading.Thread
with T800.winthread.TerminatableThread
.
from T800.winthread import TerminatableThread as Thread
t = Thread(target=run_forever) # e.g. sys.stdin.read
t.start()
...
t.terminate()
# You can even exit here though t.setDaemon(True) was not called.
import warnings
from T800.winthread import ThreadTerminationWarning
warnings.simplefilter("ignore", category=ThreadTerminationWarning)
Just Google it. :)