Skip to content

Commit

Permalink
Catch TimeoutError in worker threads looping on evaluation queue.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbywater committed Sep 21, 2017
1 parent b850051 commit bcb745a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion quantdsl/application/with_multithreading.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import six.moves.queue as queue

from quantdsl.application.base import QuantDslApplication
from quantdsl.exceptions import TimeoutError


class QuantDslApplicationWithMultithreading(QuantDslApplication):
Expand All @@ -11,6 +12,13 @@ def __init__(self, num_threads=4, *args, **kwargs):
*args, **kwargs)
# Start evaluation worker threads.
for _ in range(num_threads):
t = Thread(target=self.loop_on_evaluation_queue)
t = Thread(target=self.protected_loop_on_evaluation_queue)
t.setDaemon(True)
t.start()

def protected_loop_on_evaluation_queue(self):
try:
self.loop_on_evaluation_queue()
except TimeoutError:
# Don't need to see unhandled timeout exceptions from worker threads.
pass

0 comments on commit bcb745a

Please sign in to comment.