feat: eliminate async_timeout dep on python less than 3.11 by bdraco · Pull Request #1500 · python-zeroconf/python-zeroconf

Expand Up @@ -53,7 +53,7 @@ class AsyncEngine: "loop", "protocols", "readers", "running_event", "running_future", "senders", "zc", ) Expand All @@ -69,7 +69,7 @@ def __init__( self.protocols: list[AsyncListener] = [] self.readers: list[_WrappedTransport] = [] self.senders: list[_WrappedTransport] = [] self.running_event: asyncio.Event | None = None self.running_future: asyncio.Future[bool | None] | None = None self._listen_socket = listen_socket self._respond_sockets = respond_sockets self._cleanup_timer: asyncio.TimerHandle | None = None Expand All @@ -81,15 +81,15 @@ def setup( ) -> None: """Set up the instance.""" self.loop = loop self.running_event = asyncio.Event() self.running_future = loop.create_future() self.loop.create_task(self._async_setup(loop_thread_ready))
async def _async_setup(self, loop_thread_ready: threading.Event | None) -> None: """Set up the instance.""" self._async_schedule_next_cache_cleanup() await self._async_create_endpoints() assert self.running_event is not None self.running_event.set() assert self.running_future is not None self.running_future.set_result(True) if loop_thread_ready: loop_thread_ready.set()
Expand Down Expand Up @@ -142,8 +142,9 @@ async def _async_close(self) -> None:
def _async_shutdown(self) -> None: """Shutdown transports and sockets.""" assert self.running_event is not None self.running_event.clear() assert self.running_future is not None assert self.loop is not None self.running_future = self.loop.create_future() for wrapped_transport in itertools.chain(self.senders, self.readers): wrapped_transport.transport.close()
Expand Down