Cleanup running task before shutdown

pull/135/head
Fabian Elsner 2023-02-09 10:16:03 +01:00 zatwierdzone przez Florian Ludwig
rodzic 96e89fb37f
commit 3bf29cff4c
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -886,7 +886,7 @@ class Broker:
"Task failed and will be skipped: %s", task "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( completed, _ = await asyncio.wait(
[run_broadcast_task, self._broadcast_shutdown_waiter], [run_broadcast_task, self._broadcast_shutdown_waiter],
@ -896,6 +896,7 @@ class Broker:
# Shutdown has been triggered by the broker # Shutdown has been triggered by the broker
# So stop the loop execution # So stop the loop execution
if self._broadcast_shutdown_waiter in completed: if self._broadcast_shutdown_waiter in completed:
run_broadcast_task.cancel()
break break
except BaseException: except BaseException: