From 539047be2da1a36af9bce370cf24a7d06146481e Mon Sep 17 00:00:00 2001 From: mhchia Date: Sat, 21 Sep 2019 18:17:00 +0800 Subject: [PATCH] Make `mplex.read_message` handle `RawConnError` --- libp2p/stream_muxer/mplex/mplex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libp2p/stream_muxer/mplex/mplex.py b/libp2p/stream_muxer/mplex/mplex.py index 3d9497b..ea7e47a 100644 --- a/libp2p/stream_muxer/mplex/mplex.py +++ b/libp2p/stream_muxer/mplex/mplex.py @@ -4,6 +4,7 @@ from typing import Awaitable, Dict, List, Optional, Tuple from libp2p.exceptions import ParseError from libp2p.io.exceptions import IncompleteReadError +from libp2p.network.connection.exceptions import RawConnError from libp2p.peer.id import ID from libp2p.security.secure_conn_interface import ISecureConn from libp2p.stream_muxer.abc import IMuxedConn, IMuxedStream @@ -203,8 +204,7 @@ class Mplex(IMuxedConn): message = await asyncio.wait_for( read_varint_prefixed_bytes(self.secured_conn), timeout=5 ) - # TODO: Catch RawConnError? - except (ParseError, IncompleteReadError) as error: + except (ParseError, RawConnError, IncompleteReadError) as error: raise MplexUnavailable( "failed to read messages correctly from the underlying connection" ) from error