Reset timeout loop of worker on each iteration
If there was a next task planned very soon, this should not become the default timeout for future loop. issue11913 review415971003
This commit is contained in:
+3
-3
@@ -64,18 +64,18 @@ def work(options):
|
||||
queues = [Queue(name, mpool) for name in options.database_names]
|
||||
|
||||
tasks = TaskList()
|
||||
timeout = options.timeout
|
||||
selector = selectors.DefaultSelector()
|
||||
for queue in queues:
|
||||
selector.register(queue.connection, selectors.EVENT_READ)
|
||||
try:
|
||||
while True:
|
||||
timeout = options.timeout
|
||||
while len(tasks.filter()) >= processes:
|
||||
time.sleep(0.1)
|
||||
for queue in queues:
|
||||
task_id, next_ = queue.pull(options.name)
|
||||
timeout = min(
|
||||
next_ or options.timeout, timeout, options.timeout)
|
||||
if next_ is not None:
|
||||
timeout = min(next_, timeout)
|
||||
if task_id:
|
||||
tasks.append(queue.run(task_id))
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user