@@ -80,8 +80,7 @@ def setup(self, loop: asyncio.AbstractEventLoop, loop_thread_ready: Optional[thr
|
80 | 80 | |
81 | 81 | async def _async_setup(self, loop_thread_ready: Optional[threading.Event]) -> None: |
82 | 82 | """Set up the instance.""" |
83 | | -assert self.loop is not None |
84 | | -self._cleanup_timer = self.loop.call_later(_CACHE_CLEANUP_INTERVAL, self._async_cache_cleanup) |
| 83 | +self._async_schedule_next_cache_cleanup() |
85 | 84 | await self._async_create_endpoints() |
86 | 85 | assert self.running_event is not None |
87 | 86 | self.running_event.set() |
@@ -118,8 +117,13 @@ def _async_cache_cleanup(self) -> None:
|
118 | 117 | now, [RecordUpdate(record, record) for record in self.zc.cache.async_expire(now)] |
119 | 118 | ) |
120 | 119 | self.zc.record_manager.async_updates_complete(False) |
121 | | -assert self.loop is not None |
122 | | -self._cleanup_timer = self.loop.call_later(_CACHE_CLEANUP_INTERVAL, self._async_cache_cleanup) |
| 120 | +self._async_schedule_next_cache_cleanup() |
| 121 | + |
| 122 | +def _async_schedule_next_cache_cleanup(self) -> None: |
| 123 | +"""Schedule the next cache cleanup.""" |
| 124 | +loop = self.loop |
| 125 | +assert loop is not None |
| 126 | +self._cleanup_timer = loop.call_at(loop.time() + _CACHE_CLEANUP_INTERVAL, self._async_cache_cleanup) |
123 | 127 | |
124 | 128 | async def _async_close(self) -> None: |
125 | 129 | """Cancel and wait for the cleanup task to finish.""" |
|