mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-07 19:28:11 +08:00
Merge pull request #337 from jannero/timer-handling
Fix concurrency issue in timeout timer value processing
This commit is contained in:
@@ -209,6 +209,7 @@ class Sentinel(object):
|
|||||||
while not self.stop_event.is_set() or not counter:
|
while not self.stop_event.is_set() or not counter:
|
||||||
# Check Workers
|
# Check Workers
|
||||||
for p in self.pool:
|
for p in self.pool:
|
||||||
|
with p.timer.get_lock():
|
||||||
# Are you alive?
|
# Are you alive?
|
||||||
if not p.is_alive() or p.timer.value == 0:
|
if not p.is_alive() or p.timer.value == 0:
|
||||||
self.reincarnate(p)
|
self.reincarnate(p)
|
||||||
@@ -382,6 +383,7 @@ def worker(task_queue, result_queue, timer, timeout=Conf.TIMEOUT):
|
|||||||
result = ('{} : {}'.format(e, traceback.format_exc()), False)
|
result = ('{} : {}'.format(e, traceback.format_exc()), False)
|
||||||
if error_reporter:
|
if error_reporter:
|
||||||
error_reporter.report()
|
error_reporter.report()
|
||||||
|
with timer.get_lock():
|
||||||
# Process result
|
# Process result
|
||||||
task['result'] = result[0]
|
task['result'] = result[0]
|
||||||
task['success'] = result[1]
|
task['success'] = result[1]
|
||||||
|
|||||||
Reference in New Issue
Block a user