Add cancel messages to core task cancelation (#96972)

This commit is contained in:
J. Nick Koston 2023-07-20 18:03:36 -05:00 committed by GitHub
parent 6818cae072
commit 99def97ed9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -764,7 +764,7 @@ class HomeAssistant:
for task in self._background_tasks:
self._tasks.add(task)
task.add_done_callback(self._tasks.remove)
task.cancel()
task.cancel("Home Assistant is stopping")
self._cancel_cancellable_timers()
self.exit_code = exit_code
@ -814,7 +814,7 @@ class HomeAssistant:
"the stop event to prevent delaying shutdown",
task,
)
task.cancel()
task.cancel("Home Assistant stage 2 shutdown")
try:
async with async_timeout.timeout(0.1):
await task

View file

@ -196,7 +196,7 @@ def _cancel_all_tasks_with_timeout(
return
for task in to_cancel:
task.cancel()
task.cancel("Final process shutdown")
loop.run_until_complete(asyncio.wait(to_cancel, timeout=timeout))

View file

@ -232,7 +232,7 @@ class _GlobalTaskContext:
"""Cancel own task."""
if self._task.done():
return
self._task.cancel()
self._task.cancel("Global task timeout")
def pause(self) -> None:
"""Pause timers while it freeze."""
@ -330,7 +330,7 @@ class _ZoneTaskContext:
# Timeout
if self._task.done():
return
self._task.cancel()
self._task.cancel("Zone timeout")
def pause(self) -> None:
"""Pause timers while it freeze."""