diff --git a/libp2p/network/swarm.py b/libp2p/network/swarm.py index 5004a88..b32e46f 100644 --- a/libp2p/network/swarm.py +++ b/libp2p/network/swarm.py @@ -257,6 +257,8 @@ class Swarm(INetwork): # TODO: Should be changed to close multisple connections, # if we have several connections per peer in the future. connection = self.connections[peer_id] + # NOTE: `connection.close` performs `del self.connections[peer_id]` for us, + # so we don't need to remove the entry here. await connection.close() logger.debug("successfully close the connection to peer %s", peer_id) diff --git a/libp2p/stream_muxer/mplex/mplex_stream.py b/libp2p/stream_muxer/mplex/mplex_stream.py index 221e238..7cc0564 100644 --- a/libp2p/stream_muxer/mplex/mplex_stream.py +++ b/libp2p/stream_muxer/mplex/mplex_stream.py @@ -62,7 +62,11 @@ class MplexStream(IMuxedStream): self.event_remote_closed.wait() ) done, pending = await asyncio.wait( # type: ignore - [task_event_reset, task_incoming_data_get, task_event_remote_closed], + [ # type: ignore + task_event_reset, + task_incoming_data_get, + task_event_remote_closed, + ], return_when=asyncio.FIRST_COMPLETED, ) for fut in pending: