Skip to content

Commit

Permalink
Remove zeroconf.async_close() and use shutdown event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
shauneccles committed Jan 6, 2024
1 parent 3a095ad commit 03ecd4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion ledfx/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ async def async_stop(self, exit_code):
# Fire a shutdown event and flush the loop
self.events.fire_event(LedFxShutdownEvent())
await asyncio.sleep(0)
await self.zeroconf.async_close()
_LOGGER.info("Stopping HttpServer...")
await self.http.stop()

Expand Down
6 changes: 6 additions & 0 deletions ledfx/mdns_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
AsyncZeroconf,
)

from ledfx.events import Event
from ledfx.utils import async_fire_and_forget

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -34,6 +35,11 @@ def __init__(self, ledfx):
self.aiozc = None
self._ledfx = ledfx

def on_shutdown(e):
async_fire_and_forget(self.async_close(), self._ledfx.loop)

self._ledfx.events.add_listener(on_shutdown, Event.LEDFX_SHUTDOWN)

def on_service_state_change(
self,
zeroconf: Zeroconf,
Expand Down

0 comments on commit 03ecd4d

Please sign in to comment.