Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/zeroconf/_services/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def instance_name_from_service_info(info: "ServiceInfo") -> str:
_cached_ip_addresses = lru_cache(maxsize=256)(ip_address)


def _set_future_none_if_not_done(fut: asyncio.Future) -> None:
"""Set a future to None if it is not done."""
if not fut.done(): # pragma: no branch
fut.set_result(None)


class ServiceInfo(RecordUpdateListener):
"""Service information.

Expand Down Expand Up @@ -235,7 +241,7 @@ async def async_wait(self, timeout: float) -> None:
loop = asyncio.get_running_loop()
future = loop.create_future()
self._new_records_futures.append(future)
handle = loop.call_later(millis_to_seconds(timeout), future.set_result, None)
handle = loop.call_later(millis_to_seconds(timeout), _set_future_none_if_not_done, future)
try:
await future
finally:
Expand Down