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
13 changes: 8 additions & 5 deletions src/zeroconf/_services/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ def properties(self) -> Dict[Union[str, bytes], Optional[Union[str, bytes]]]:
assert self._properties is not None
return self._properties

async def async_wait(self, timeout: float) -> None:
async def async_wait(self, timeout: float, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
"""Calling task waits for a given number of milliseconds or until notified."""
loop = get_running_loop()
assert loop is not None
await wait_for_future_set_or_timeout(loop, self._new_records_futures, timeout)
await wait_for_future_set_or_timeout(
loop or asyncio.get_running_loop(), self._new_records_futures, timeout
)

def addresses_by_version(self, version: IPVersion) -> List[bytes]:
"""List addresses matching IP version.
Expand Down Expand Up @@ -722,6 +722,9 @@ async def async_request(
if self.load_from_cache(zc, now):
return True

if TYPE_CHECKING:
assert zc.loop is not None

first_request = True
delay = _LISTENER_TIME
next_ = now
Expand All @@ -743,7 +746,7 @@ async def async_request(
delay *= 2
next_ += random.randint(*_AVOID_SYNC_DELAY_RANDOM_INTERVAL)

await self.async_wait(min(next_, last) - now)
await self.async_wait(min(next_, last) - now, zc.loop)
now = current_time_millis()
finally:
zc.async_remove_listener(self)
Expand Down