From 82dc5d9e3161111076dd5e5eba2336436d102b72 Mon Sep 17 00:00:00 2001 From: mhchia Date: Wed, 2 Oct 2019 15:45:54 +0800 Subject: [PATCH] Ignore typing for `asyncio.wait` --- libp2p/network/swarm.py | 2 ++ libp2p/stream_muxer/mplex/mplex_stream.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libp2p/network/swarm.py b/libp2p/network/swarm.py index 5004a889..b32e46f9 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 221e238e..7cc0564e 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: