Speed up zeroconf reconnect logic (#531)

This commit is contained in:
J. Nick Koston 2023-08-29 08:02:53 -05:00 committed by GitHub
parent 55d112c89e
commit fee26d5387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -19,6 +19,7 @@ _LOGGER = logging.getLogger(__name__)
EXPECTED_DISCONNECT_COOLDOWN = 3.0
MAXIMUM_BACKOFF_TRIES = 100
TYPE_PTR = 12
class ReconnectLogic(zeroconf.RecordUpdateListener):
@ -263,9 +264,10 @@ class ReconnectLogic(zeroconf.RecordUpdateListener):
for record_update in records:
# We only consider PTR records and match using the alias name
new_record = record_update.new
if (
not isinstance(record_update.new, zeroconf.DNSPointer) # type: ignore[attr-defined]
or record_update.new.alias != self._filter_alias
new_record.type != TYPE_PTR
or new_record.alias != self._filter_alias # type: ignore[attr-defined]
):
continue