Merge branch 'master' into fix/change-notifee-and-add-tests-for-swarm-conn-and-mplex

This commit is contained in:
mhchia
2019-09-21 18:34:12 +08:00
22 changed files with 226 additions and 68 deletions

View File

@ -2,7 +2,9 @@ import asyncio
from typing import Any # noqa: F401
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
@ -193,14 +195,12 @@ class Mplex(IMuxedConn):
"""
# FIXME: No timeout is used in Go implementation.
# Timeout is set to a relatively small value to alleviate wait time to exit
# loop in handle_incoming
try:
header = await decode_uvarint_from_stream(self.secured_conn)
message = await asyncio.wait_for(
read_varint_prefixed_bytes(self.secured_conn), timeout=5
)
except (ConnectionResetError, IncompleteReadError) as error:
except (ParseError, RawConnError, IncompleteReadError) as error:
raise MplexUnavailable(
"failed to read messages correctly from the underlying connection"
) from error