From 5b03a7ad9f801fe7fa26c70515dadbe2e9bf799e Mon Sep 17 00:00:00 2001 From: mhchia Date: Wed, 5 Feb 2020 21:41:28 +0800 Subject: [PATCH] Mplex: only close the send of new stream channel --- libp2p/stream_muxer/mplex/mplex.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libp2p/stream_muxer/mplex/mplex.py b/libp2p/stream_muxer/mplex/mplex.py index ddeb41f4..4f62e152 100644 --- a/libp2p/stream_muxer/mplex/mplex.py +++ b/libp2p/stream_muxer/mplex/mplex.py @@ -137,7 +137,7 @@ class Mplex(IMuxedConn): """accepts a muxed stream opened by the other end.""" try: return await self.new_stream_receive_channel.receive() - except (trio.ClosedResourceError, trio.EndOfChannel): + except trio.EndOfChannel: raise MplexUnavailable async def send_message( @@ -254,7 +254,7 @@ class Mplex(IMuxedConn): mplex_stream = await self._initialize_stream(stream_id, message.decode()) try: await self.new_stream_send_channel.send(mplex_stream) - except (trio.BrokenResourceError, trio.ClosedResourceError): + except trio.ClosedResourceError: raise MplexUnavailable async def _handle_message(self, stream_id: StreamID, message: bytes) -> None: @@ -336,6 +336,4 @@ class Mplex(IMuxedConn): send_channel = self.streams_msg_channels[stream_id] await send_channel.aclose() self.event_closed.set() - # FIXME: It's enough to just close one side. await self.new_stream_send_channel.aclose() - await self.new_stream_receive_channel.aclose()