Skip to content

Commit

Permalink
Cleanup running task before shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianElsmer authored and FlorianLudwig committed Feb 9, 2023
1 parent 96e89fb commit 3bf29cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion amqtt/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ async def _broadcast_loop(self):
"Task failed and will be skipped: %s", task
)

run_broadcast_task = self._run_broadcast(running_tasks)
run_broadcast_task = asyncio.Task(self._run_broadcast(running_tasks))

completed, _ = await asyncio.wait(
[run_broadcast_task, self._broadcast_shutdown_waiter],
Expand All @@ -896,6 +896,7 @@ async def _broadcast_loop(self):
# Shutdown has been triggered by the broker
# So stop the loop execution
if self._broadcast_shutdown_waiter in completed:
run_broadcast_task.cancel()
break

except BaseException:
Expand Down

0 comments on commit 3bf29cf

Please sign in to comment.