FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add ENETUNREACH to non-retryable errors in XorTransport (#1668) · python-kasa/python-kasa@99fca94 · GitHub

Repository navigation

Commit 99fca94

Browse files
authored
Add ENETUNREACH to non-retryable errors in XorTransport (#1668)
`ENETUNREACH` is semantically equivalent to `EHOSTUNREACH` (which is already in `_NO_RETRY_ERRORS`) — both indicate the destination cannot be reached at the network layer. Retrying immediately will not resolve the condition. In containerized environments (e.g., Home Assistant running in Docker with bridge networking), a single ICMP "Network unreachable" response can temporarily poison the container's routing cache. The unnecessary retries reinforce the poisoned cache entry, causing cascading failures for other devices on the same subnet.
1 parent be5ce08 commit 99fca94

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎kasa/transports/xortransport.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
from .basetransport import BaseTransport
3030

3131
_LOGGER = logging.getLogger(__name__)
32-
_NO_RETRY_ERRORS = {errno.EHOSTDOWN, errno.EHOSTUNREACH, errno.ECONNREFUSED}
32+
_NO_RETRY_ERRORS = {
33+
errno.EHOSTDOWN,
34+
errno.EHOSTUNREACH,
35+
errno.ENETUNREACH,
36+
errno.ECONNREFUSED,
37+
}
3338
_UNSIGNED_INT_NETWORK_ORDER = struct.Struct(">I")
3439

3540

‎tests/protocols/test_iotprotocol.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,10 +807,17 @@ async def test_transport_credentials_hash_from_config(mocker, transport_class):
807807
[
808808
(ConnectionRefusedError("dummy exception"), False),
809809
(OSError(errno.EHOSTDOWN, os.strerror(errno.EHOSTDOWN)), False),
810+
(OSError(errno.ENETUNREACH, os.strerror(errno.ENETUNREACH)), False),
810811
(OSError(errno.ECONNRESET, os.strerror(errno.ECONNRESET)), True),
811812
(Exception("dummy exception"), True),
812813
],
813-
ids=("ConnectionRefusedError", "OSErrorNoRetry", "OSErrorRetry", "Exception"),
814+
ids=(
815+
"ConnectionRefusedError",
816+
"OSErrorHostDown",
817+
"OSErrorNetUnreach",
818+
"OSErrorRetry",
819+
"Exception",
820+
),
814821
)
815822
@pytest.mark.parametrize(
816823
("protocol_class", "transport_class"),

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL