Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion libp2p/kad_dht/provider_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ async def _send_add_provider(self, peer_id: ID, key: bytes) -> bool:
True if the message was successfully sent and acknowledged

"""
stream = None

try:
result = False
# Open a stream to the peer
Expand Down Expand Up @@ -298,7 +300,8 @@ async def _send_add_provider(self, peer_id: ID, key: bytes) -> bool:
logger.warning(f"Error sending ADD_PROVIDER to {peer_id}: {e}")

finally:
await stream.close()
if stream is not None:
await stream.close()
return result

async def find_providers(self, key: bytes, count: int = 20) -> list[PeerInfo]:
Expand Down