Skip to content

Commit 5262566

Browse files
committed
fix: check for mDNS attribute before accessing it in BasicHost
1 parent f274d20 commit 5262566

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libp2p/host/basic_host.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ async def _run() -> AsyncIterator[None]:
166166
network = self.get_network()
167167
async with background_trio_service(network):
168168
await network.listen(*listen_addrs)
169-
if self.mDNS is not None:
169+
if hasattr(self, "mDNS") and self.mDNS is not None:
170170
logger.debug("Starting mDNS Discovery")
171171
self.mDNS.start()
172172
try:
173173
yield
174174
finally:
175-
if self.mDNS is not None:
175+
if hasattr(self, "mDNS") and self.mDNS is not None:
176176
self.mDNS.stop()
177177

178178
return _run()

0 commit comments

Comments
 (0)