Use builtin TimeoutError [t-z] (#109683)
This commit is contained in:
parent
438d3b01b9
commit
8b0c9d3d18
63 changed files with 88 additions and 122 deletions
|
@ -1,7 +1,6 @@
|
|||
"""Connection session."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Callable, Hashable
|
||||
from contextvars import ContextVar
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
@ -266,7 +265,7 @@ class ActiveConnection:
|
|||
elif isinstance(err, vol.Invalid):
|
||||
code = const.ERR_INVALID_FORMAT
|
||||
err_message = vol.humanize.humanize_error(msg, err)
|
||||
elif isinstance(err, asyncio.TimeoutError):
|
||||
elif isinstance(err, TimeoutError):
|
||||
code = const.ERR_TIMEOUT
|
||||
err_message = "Timeout"
|
||||
elif isinstance(err, HomeAssistantError):
|
||||
|
|
|
@ -282,7 +282,7 @@ class WebSocketHandler:
|
|||
try:
|
||||
async with asyncio.timeout(10):
|
||||
await wsock.prepare(request)
|
||||
except asyncio.TimeoutError:
|
||||
except TimeoutError:
|
||||
self._logger.warning("Timeout preparing request from %s", request.remote)
|
||||
return wsock
|
||||
|
||||
|
@ -310,7 +310,7 @@ class WebSocketHandler:
|
|||
# Auth Phase
|
||||
try:
|
||||
msg = await wsock.receive(10)
|
||||
except asyncio.TimeoutError as err:
|
||||
except TimeoutError as err:
|
||||
disconnect_warn = "Did not receive auth message within 10 seconds"
|
||||
raise Disconnect from err
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue