From 7da36eccbd92a34a1cb47b95d21c30f0969c0a82 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Tue, 7 Feb 2017 20:47:28 +0100 Subject: [PATCH] Signal sender threads to close on shutdown - when shutdown is running, add a shutdown command to the queues of all sender threads --- src/shared.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/shared.py b/src/shared.py index 5582a961..d84ec191 100644 --- a/src/shared.py +++ b/src/shared.py @@ -227,9 +227,12 @@ def doCleanShutdown(): # Wait long enough to guarantee that any running proof of work worker threads will check the # shutdown variable and exit. If the main thread closes before they do then they won't stop. time.sleep(.25) - + from class_outgoingSynSender import outgoingSynSender + from class_sendDataThread import sendDataThread for thread in threading.enumerate(): + if isinstance(thread, sendDataThread): + thread.sendDataThreadQueue.put((0, 'shutdown','no data')) if thread is not threading.currentThread() and isinstance(thread, StoppableThread) and not isinstance(thread, outgoingSynSender): logger.debug("Waiting for thread %s", thread.name) thread.join()