Make ThreadPool a context manager to prevent memory leaks
This commit is contained in:
parent
c4f65a5d7b
commit
09e65e1d95
3 changed files with 99 additions and 99 deletions
|
@ -55,6 +55,12 @@ class ThreadPool:
|
|||
del self.pool
|
||||
self.pool = None
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
self.kill()
|
||||
|
||||
|
||||
lock_pool = gevent.threadpool.ThreadPool(50)
|
||||
main_thread_id = threading.current_thread().ident
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue