mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 01:08:12 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user