From 550b4236d100151769abe9bcf9e1a3d099d7d7be Mon Sep 17 00:00:00 2001 From: Marin Atanasov Nikolov Date: Mon, 14 Oct 2013 12:32:14 +0300 Subject: [PATCH] Give some time for the threads to synchronize before starting them * Set the daemon flag of the threads during instantiation --- src/vmpoller/core.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/vmpoller/core.py b/src/vmpoller/core.py index caf9e45..1f7cb6a 100644 --- a/src/vmpoller/core.py +++ b/src/vmpoller/core.py @@ -206,12 +206,15 @@ def run(self, config_file, start_agents=True): # Create a DEALER socket for passing messages from our worker threads back to the clients self.dealer = self.zcontext.socket(zmq.DEALER) self.dealer.bind("inproc://workers") - + + # Create our threads for i in xrange(self.threads_num): - thread = threading.Thread(target=self.worker_thread, args=("inproc://workers", self.zcontext)) + thread = threading.Thread(target=self.worker_thread, args=("inproc://workers", self.zcontext), daemon=True) self.threads.append(thread) - thread.daemon = True - thread.start() + + # Start our threads + for eachThread in self.threads: + eachThread.start() #zmq.proxy(self.router, self.dealer)