diff --git a/noblogsmv/state.py b/noblogsmv/state.py index 60a8ef3822b849567d472038b6254ca6fa21de2f..9cf2c90db5e7124385b505ebed5cf3ab83ed89e8 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: