Skip to content
Snippets Groups Projects
Commit 0c397c63 authored by ale's avatar ale
Browse files

start workers after data is loaded

parent 91ae5732
No related branches found
No related tags found
No related merge requests found
...@@ -358,20 +358,22 @@ class StateMachine(object): ...@@ -358,20 +358,22 @@ class StateMachine(object):
def run(self): def run(self):
input_queue = Queue.Queue() input_queue = Queue.Queue()
self.threads = [ self.threads = [
StateMachineWorker(self, input_queue, i + 1) StateMachineWorker(self, input_queue, i + 1)
for i in xrange(self.num_workers)] for i in xrange(self.num_workers)]
[x.start() for x in self.threads]
stats_thread = StatsThread(self) stats_thread = StatsThread(self)
stats_thread.start() stats_thread.start()
self.running = True
# Inject initial state. # Inject initial state.
with readonly_transaction(self.db) as session: with readonly_transaction(self.db) as session:
for key in self.db.scan(session): for key in self.db.scan(session):
input_queue.put(key) 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. # Wait until everything is done.
while True: while True:
try: try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment