Kill threadpool properly

This commit is contained in:
shortcutme 2019-12-17 14:50:10 +01:00
parent 495d695c5a
commit b21895fa78
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -48,6 +48,17 @@ class ThreadPool:
else: else:
return t.get() return t.get()
def kill(self):
if self.pool is not None and self.pool.size > 0 and main_loop:
main_loop.call(self.pool.kill)
del self.pool
self.pool = None
def __del__(self):
self.kill()
lock_pool = gevent.threadpool.ThreadPool(50) lock_pool = gevent.threadpool.ThreadPool(50)
main_thread_id = threading.current_thread().ident main_thread_id = threading.current_thread().ident