Skip to content

Commit

Permalink
task_procesing: tasks resulting from hooks go to priority queue
Browse files Browse the repository at this point in the history
To avoid a potential deadlock, new tasks resulting from hooked functions (in secondary modules) must be written to the priority queue, not the normal one.
  • Loading branch information
vaclavbartos committed Jul 7, 2023
1 parent 576c79b commit 5db0849
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dp3/task_processing/task_distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,13 @@ def _worker_func(self, thread_index):
)
)

# Push tasks
# Push new tasks (resulting from hooks) to the priority queue.
# (priority queue is not limited in size, so put_task() never blocks; the normal
# queue has limited size, so if it was used here, a deadlock could occur if all
# workers try to push new tasks to a full queue)
try:
for task in new_tasks:
self._task_queue_writer.put_task(task)
self._task_queue_writer.put_task(task, priority=True)
except Exception as e:
self.log.error(f"Failed to push tasks created from hooks: {e}")

Expand Down

0 comments on commit 5db0849

Please sign in to comment.