bpo-36813: Fix QueueListener to call task_done() upon termination. (GH-13113)

Fixed QueueListener in order to avoid random deadlocks.
Unable to add regression tests atm due to time constraints, will add it in a bit.
Regarding implementation, although it's nested, it does not cause performance issues whatsoever, and does not call task_done() in case of an exception (which is the right thing to do IMHO).


https://bugs.python.org/issue36813
This commit is contained in:
Bar Harel 2019-06-01 12:19:09 +03:00 committed by Miss Islington (bot)
parent 70c5f2ae6e
commit 6b282e1887
3 changed files with 14 additions and 0 deletions

View file

@ -1477,6 +1477,8 @@ class QueueListener(object):
try:
record = self.dequeue(True)
if record is self._sentinel:
if has_task_done:
q.task_done()
break
self.handle(record)
if has_task_done: