Adds timeout mechanism for workers

Workers now share a ctype with the sentinel to indicate if they are currently executing a task.  This timer is incremented each guard loop until the worker resets it after finishing a job or until it reaches the TIMEOUT value and the worker is terminated by the sentinel.
This commit is contained in:
Ilan Steemers
2015-07-01 10:54:36 +02:00
parent 5937f55fc5
commit 4e38925cea
4 changed files with 23 additions and 11 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
from multiprocessing import Queue, Event
from multiprocessing import Queue, Event, Value
import pytest
@@ -34,7 +34,7 @@ def test_scheduler(r):
task_queue.put('STOP')
# let a worker handle them
result_queue = Queue()
worker(task_queue, result_queue)
worker(task_queue, result_queue, Value('b', -1))
assert result_queue.qsize() == 1
result_queue.put('STOP')
# store the results