From 66c6227911469bbeb55d78e8379a511932300538 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 16 Sep 2021 13:11:51 -1000 Subject: [PATCH 1/2] Collapse _GLOBAL_DONE into done - Since there the other attributes are not protected, it was inconsistent to protect this one. --- zeroconf/_core.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/zeroconf/_core.py b/zeroconf/_core.py index c9c4c5ec9..1dd0efb36 100644 --- a/zeroconf/_core.py +++ b/zeroconf/_core.py @@ -401,7 +401,7 @@ def __init__( ip_version = autodetect_ip_version(interfaces) # hook for threads - self._GLOBAL_DONE = False + self.done = False if apple_p2p and sys.platform != 'darwin': raise RuntimeError('Option `apple_p2p` is not supported on non-Apple platforms.') @@ -456,10 +456,6 @@ async def async_wait_for_start(self) -> None: """Wait for start up.""" await self.engine.async_wait_for_start() - @property - def done(self) -> bool: - return self._GLOBAL_DONE - @property def listeners(self) -> List[RecordUpdateListener]: return self.record_manager.listeners @@ -815,7 +811,7 @@ def async_send( transport: Optional[asyncio.DatagramTransport] = None, ) -> None: """Sends an outgoing packet.""" - if self._GLOBAL_DONE: + if self.done: return # If no transport is specified, we send to all the ones @@ -866,10 +862,10 @@ def _async_send_transport( def _close(self) -> None: """Set global done and remove all service listeners.""" - if self._GLOBAL_DONE: + if self.done: return self.remove_all_service_listeners() - self._GLOBAL_DONE = True + self.done = True def _shutdown_threads(self) -> None: """Shutdown any threads.""" From 459e2426529f2b0f241cfe926d39ac7bc57d081d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 16 Sep 2021 13:15:18 -1000 Subject: [PATCH 2/2] Update zeroconf/_core.py --- zeroconf/_core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/zeroconf/_core.py b/zeroconf/_core.py index 1dd0efb36..f4161877c 100644 --- a/zeroconf/_core.py +++ b/zeroconf/_core.py @@ -400,7 +400,6 @@ def __init__( if ip_version is None: ip_version = autodetect_ip_version(interfaces) - # hook for threads self.done = False if apple_p2p and sys.platform != 'darwin':