Skip to content

Commit

Permalink
support.task_queue: clear done queue after cancellation.
Browse files Browse the repository at this point in the history
Since .cancel() waits until all live tasks are done, it is likely
that the done queue will contain some cancelled tasks. If the done
queue is not cleared, then the next poll()/wait_one()/wait_all() call
will cancel the caller, which usually silently terminates it. In any
case, semantically .cancel() discards the results of all tasks in
the queue even if they completed before they were cancelled.

This bug was introduced in commit a7d041f.

Fixes #202.

Co-authored-by: Filipe Laíns <lains@archlinux.org>
  • Loading branch information
whitequark and FFY00 committed Oct 16, 2020
1 parent 5307005 commit 1dbfc8e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions software/glasgow/support/task_queue.py
Expand Up @@ -40,6 +40,7 @@ async def cancel(self):
task.cancel()
if self._live:
await asyncio.wait(self._live, return_when=asyncio.ALL_COMPLETED)
self._done.clear()

async def poll(self):
"""
Expand Down

0 comments on commit 1dbfc8e

Please sign in to comment.