fix: check for mDNS attribute before accessing it in BasicHost

This commit is contained in:
sumanjeet0012@gmail.com
2025-06-26 00:36:59 +05:30
parent f274d20715
commit 5262566f6a

View File

@ -166,13 +166,13 @@ class BasicHost(IHost):
network = self.get_network()
async with background_trio_service(network):
await network.listen(*listen_addrs)
if self.mDNS is not None:
if hasattr(self, "mDNS") and self.mDNS is not None:
logger.debug("Starting mDNS Discovery")
self.mDNS.start()
try:
yield
finally:
if self.mDNS is not None:
if hasattr(self, "mDNS") and self.mDNS is not None:
self.mDNS.stop()
return _run()