Stopping daemonized threads when references to these threads are lost
This commit is contained in:
@@ -127,6 +127,7 @@ class Producer(object):
|
|||||||
self.async = async
|
self.async = async
|
||||||
self.req_acks = req_acks
|
self.req_acks = req_acks
|
||||||
self.ack_timeout = ack_timeout
|
self.ack_timeout = ack_timeout
|
||||||
|
self.stopped = False
|
||||||
|
|
||||||
if codec is None:
|
if codec is None:
|
||||||
codec = CODEC_NONE
|
codec = CODEC_NONE
|
||||||
@@ -212,3 +213,8 @@ class Producer(object):
|
|||||||
|
|
||||||
if self.proc.is_alive():
|
if self.proc.is_alive():
|
||||||
self.proc.terminate()
|
self.proc.terminate()
|
||||||
|
self.stopped = True
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
if not self.stopped:
|
||||||
|
self.stop()
|
||||||
|
@@ -151,3 +151,6 @@ class ReentrantTimer(object):
|
|||||||
# noinspection PyAttributeOutsideInit
|
# noinspection PyAttributeOutsideInit
|
||||||
self.timer = None
|
self.timer = None
|
||||||
self.fn = None
|
self.fn = None
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.stop()
|
||||||
|
Reference in New Issue
Block a user