Stopping daemonized threads when references to these threads are lost

This commit is contained in:
Christophe-Marie Duquesne
2015-02-17 00:50:51 +01:00
parent 9ad0be662d
commit 04979248af
2 changed files with 9 additions and 0 deletions

View File

@@ -127,6 +127,7 @@ class Producer(object):
self.async = async
self.req_acks = req_acks
self.ack_timeout = ack_timeout
self.stopped = False
if codec is None:
codec = CODEC_NONE
@@ -212,3 +213,8 @@ class Producer(object):
if self.proc.is_alive():
self.proc.terminate()
self.stopped = True
def __del__(self):
if not self.stopped:
self.stop()

View File

@@ -151,3 +151,6 @@ class ReentrantTimer(object):
# noinspection PyAttributeOutsideInit
self.timer = None
self.fn = None
def __del__(self):
self.stop()