Skip to content

Commit

Permalink
await canceled tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Sep 17, 2024
1 parent 3a8636c commit 3f6051a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bbot/core/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ async def finished_tasks(self, tasks, timeout=None):
self.log.warning(f"{self.name}: Timeout after {timeout:,} seconds in finished_tasks({tasks})")
for task in tasks:
task.cancel()
self._await_cancelled_task(task)
else:
if not in_exception_chain(e, (KeyboardInterrupt, asyncio.CancelledError)):
self.log.error(f"{self.name}: Unhandled exception in finished_tasks({tasks}): {e}")
Expand All @@ -664,7 +665,7 @@ async def cancel_task(self, client_id):
child_task.cancel()

for task in [parent_task] + list(child_tasks):
await self._cancel_task(task)
await self._await_cancelled_task(task)

async def _await_cancelled_task(self, task):
try:
Expand All @@ -683,4 +684,4 @@ async def cancel_all_tasks(self):
await self.cancel_task(client_id)
for client_id, tasks in self.child_tasks.items():
for task in tasks:
await self._cancel_task(task)
await self._await_cancelled_task(task)

0 comments on commit 3f6051a

Please sign in to comment.