@@ -263,11 +263,11 @@ def properties(self) -> Dict[Union[str, bytes], Optional[Union[str, bytes]]]:
|
263 | 263 | assert self._properties is not None |
264 | 264 | return self._properties |
265 | 265 | |
266 | | -async def async_wait(self, timeout: float) -> None: |
| 266 | +async def async_wait(self, timeout: float, loop: Optional[asyncio.AbstractEventLoop] = None) -> None: |
267 | 267 | """Calling task waits for a given number of milliseconds or until notified.""" |
268 | | -loop = get_running_loop() |
269 | | -assert loop is not None |
270 | | -await wait_for_future_set_or_timeout(loop, self._new_records_futures, timeout) |
| 268 | +await wait_for_future_set_or_timeout( |
| 269 | + loop or asyncio.get_running_loop(), self._new_records_futures, timeout |
| 270 | + ) |
271 | 271 | |
272 | 272 | def addresses_by_version(self, version: IPVersion) -> List[bytes]: |
273 | 273 | """List addresses matching IP version. |
@@ -722,6 +722,9 @@ async def async_request(
|
722 | 722 | if self.load_from_cache(zc, now): |
723 | 723 | return True |
724 | 724 | |
| 725 | +if TYPE_CHECKING: |
| 726 | +assert zc.loop is not None |
| 727 | + |
725 | 728 | first_request = True |
726 | 729 | delay = _LISTENER_TIME |
727 | 730 | next_ = now |
@@ -743,7 +746,7 @@ async def async_request(
|
743 | 746 | delay *= 2 |
744 | 747 | next_ += random.randint(*_AVOID_SYNC_DELAY_RANDOM_INTERVAL) |
745 | 748 | |
746 | | -await self.async_wait(min(next_, last) - now) |
| 749 | +await self.async_wait(min(next_, last) - now, zc.loop) |
747 | 750 | now = current_time_millis() |
748 | 751 | finally: |
749 | 752 | zc.async_remove_listener(self) |
|