From 0c397c6335a5a565a0090fe01e99de93954f80e9 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Sun, 10 Nov 2013 17:00:26 +0000
Subject: [PATCH] start workers after data is loaded

---
 noblogsmv/state.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/noblogsmv/state.py b/noblogsmv/state.py
index 60a8ef3..9cf2c90 100644
--- a/noblogsmv/state.py
+++ b/noblogsmv/state.py
@@ -358,20 +358,22 @@ class StateMachine(object):
 
     def run(self):
         input_queue = Queue.Queue()
-
         self.threads = [
             StateMachineWorker(self, input_queue, i + 1)
             for i in xrange(self.num_workers)]
-        [x.start() for x in self.threads]
+
         stats_thread = StatsThread(self)
         stats_thread.start()
-        self.running = True
 
         # Inject initial state.
         with readonly_transaction(self.db) as session:
             for key in self.db.scan(session):
                 input_queue.put(key)
 
+        # Start the workers after all the data has been loaded.
+        [x.start() for x in self.threads]
+        self.running = True
+
         # Wait until everything is done.
         while True:
             try:
-- 
GitLab