diff --git a/homeassistant/core.py b/homeassistant/core.py index 54f44d0998c..6ea03e85c43 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -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 diff --git a/homeassistant/runner.py b/homeassistant/runner.py index 9a86bed7594..67ec232db9c 100644 --- a/homeassistant/runner.py +++ b/homeassistant/runner.py @@ -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)) diff --git a/homeassistant/util/timeout.py b/homeassistant/util/timeout.py index df225580dae..9d9f5d986a0 100644 --- a/homeassistant/util/timeout.py +++ b/homeassistant/util/timeout.py @@ -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."""