mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-05-30 21:51:24 +00:00
Improve timeout error reporting
This commit is contained in:
parent
1f45f425a0
commit
c5bf1ccc4e
@ -126,6 +126,12 @@ class XorTransport(BaseTransport):
|
|||||||
# This is especially import when there are multiple tplink devices being polled.
|
# This is especially import when there are multiple tplink devices being polled.
|
||||||
try:
|
try:
|
||||||
await self._connect(self._timeout)
|
await self._connect(self._timeout)
|
||||||
|
except TimeoutError as ex:
|
||||||
|
await self.reset()
|
||||||
|
raise _RetryableError(
|
||||||
|
f"Timeout after {self._timeout} seconds connecting to the device:"
|
||||||
|
f" {self._host}:{self._port}: {ex}"
|
||||||
|
) from ex
|
||||||
except ConnectionRefusedError as ex:
|
except ConnectionRefusedError as ex:
|
||||||
await self.reset()
|
await self.reset()
|
||||||
raise KasaException(
|
raise KasaException(
|
||||||
@ -159,6 +165,12 @@ class XorTransport(BaseTransport):
|
|||||||
assert self.writer is not None # noqa: S101
|
assert self.writer is not None # noqa: S101
|
||||||
async with asyncio_timeout(self._timeout):
|
async with asyncio_timeout(self._timeout):
|
||||||
return await self._execute_send(request)
|
return await self._execute_send(request)
|
||||||
|
except TimeoutError as ex:
|
||||||
|
await self.reset()
|
||||||
|
raise _RetryableError(
|
||||||
|
f"Timeout after {self._timeout} seconds sending request to the device"
|
||||||
|
f" {self._host}:{self._port}: {ex}"
|
||||||
|
) from ex
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
await self.reset()
|
await self.reset()
|
||||||
raise _RetryableError(
|
raise _RetryableError(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user