Make mplex.read_message handle RawConnError

This commit is contained in:
mhchia 2019-09-21 18:17:00 +08:00
parent e44c2145cc
commit 539047be2d
No known key found for this signature in database
GPG Key ID: 389EFBEA1362589A

View File

@ -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