From ab25c5a2bdb010fc9ae68bdc0eb5a96dc461e46d Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 11 Jan 2021 09:36:14 +0100 Subject: [PATCH] Shutdown asyncio http server within 10 seconds (#45033) If there are open requests, the http server waits up to 60 seconds. However, some requests (such as the Reboot button) seems to keep a connection open and needlessly slow down the reboot process: ``` Jan 11 00:52:54 homeassistant eb034fca9c7d[404]: 2021-01-11 00:52:54 DEBUG (MainThread) [homeassistant.core] Bus:Handling Jan 11 00:52:54 homeassistant eb034fca9c7d[404]: 2021-01-11 00:52:54 DEBUG (MainThread) [homeassistant.helpers.restore_state] Dumping states 111 Jan 11 00:52:54 homeassistant eb034fca9c7d[404]: 2021-01-11 00:52:54 DEBUG (MainThread) [homeassistant.helpers.restore_state] Dumping states Jan 11 00:52:54 homeassistant eb034fca9c7d[404]: 2021-01-11 00:52:54 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [281473359593728] Connection closed by client Jan 11 00:52:56 homeassistant eb034fca9c7d[404]: 2021-01-11 00:52:56 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [281473359593728] Disconnected Jan 11 00:53:54 homeassistant eb034fca9c7d[404]: 2021-01-11 00:53:54 DEBUG (MainThread) [homeassistant.core] Waited 60 seconds for task: .stop_server() running at /usr/src/homeassistant/homeassistant/components/http/__init__.py:228> wait_for=<_GatheringFuture pending cb=[()]> cb=[_wait.._on_completion() at /usr/local/lib/python3.8/asyncio/tasks.py:518]> ... ``` --- homeassistant/components/http/web_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/http/web_runner.py b/homeassistant/components/http/web_runner.py index 67621d63412..c30ba32b780 100644 --- a/homeassistant/components/http/web_runner.py +++ b/homeassistant/components/http/web_runner.py @@ -28,7 +28,7 @@ class HomeAssistantTCPSite(web.BaseSite): host: Union[None, str, List[str]], port: int, *, - shutdown_timeout: float = 60.0, + shutdown_timeout: float = 10.0, ssl_context: Optional[SSLContext] = None, backlog: int = 128, reuse_address: Optional[bool] = None,