Skip to content

Commit

Permalink
fix: handle Dbus EOFError while connecting (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Sep 10, 2022
1 parent acbee38 commit b0bc92d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/bleak_retry_connector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,19 @@ def _raise_if_needed(name: str, description: str, exc: Exception) -> None:
device.rssi,
)
_raise_if_needed(name, description, exc)
except EOFError as exc:
transient_errors += 1
_LOGGER.debug(
"%s - %s: Failed to connect: %s, backing off: %s (attempt: %s, last rssi: %s)",
name,
description,
str(exc),
BLEAK_DBUS_BACKOFF_TIME,
attempt,
device.rssi,
)
await asyncio.sleep(BLEAK_DBUS_BACKOFF_TIME)
_raise_if_needed(name, description, exc)
except BLEAK_EXCEPTIONS as exc:
bleak_error = str(exc)
if any(error in bleak_error for error in TRANSIENT_ERRORS):
Expand All @@ -400,7 +413,7 @@ def _raise_if_needed(name: str, description: str, exc: Exception) -> None:
"%s - %s: Failed to connect: %s, backing off: %s (attempt: %s, last rssi: %s)",
name,
description,
str(exc),
bleak_error,
BLEAK_DBUS_BACKOFF_TIME,
attempt,
device.rssi,
Expand All @@ -411,7 +424,7 @@ def _raise_if_needed(name: str, description: str, exc: Exception) -> None:
"%s - %s: Failed to connect: %s (attempt: %s, last rssi: %s)",
name,
description,
str(exc),
bleak_error,
attempt,
device.rssi,
)
Expand Down

0 comments on commit b0bc92d

Please sign in to comment.