Skip to content

Commit

Permalink
Log futures that are blocking shutdown stages (#88736)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Feb 25, 2023
1 parent 0f204d6 commit 7b61d37
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ async def async_stop(self, exit_code: int = 0, *, force: bool = False) -> None:
"Timed out waiting for shutdown stage 1 to complete, the shutdown will"
" continue"
)
self._async_log_running_tasks(1)

# stage 2
self.state = CoreState.final_write
Expand All @@ -742,6 +743,7 @@ async def async_stop(self, exit_code: int = 0, *, force: bool = False) -> None:
"Timed out waiting for shutdown stage 2 to complete, the shutdown will"
" continue"
)
self._async_log_running_tasks(2)

# stage 3
self.state = CoreState.not_running
Expand All @@ -762,11 +764,18 @@ async def async_stop(self, exit_code: int = 0, *, force: bool = False) -> None:
"Timed out waiting for shutdown stage 3 to complete, the shutdown will"
" continue"
)
self._async_log_running_tasks(3)

self.state = CoreState.stopped

if self._stopped is not None:
self._stopped.set()

def _async_log_running_tasks(self, stage: int) -> None:
"""Log all running tasks."""
for task in self._tasks:
_LOGGER.warning("Shutdown stage %s: still running: %s", stage, task)


class Context:
"""The context that triggered something."""
Expand Down

0 comments on commit 7b61d37

Please sign in to comment.