mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Merge branch 'master' into fix/refactor-mplex-swarm-host
This commit is contained in:
@ -2,6 +2,8 @@ import asyncio
|
||||
from typing import Any # noqa: F401
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
from libp2p.exceptions import ParseError
|
||||
from libp2p.io.exceptions import IncompleteReadError
|
||||
from libp2p.peer.id import ID
|
||||
from libp2p.security.secure_conn_interface import ISecureConn
|
||||
from libp2p.stream_muxer.abc import IMuxedConn, IMuxedStream
|
||||
@ -243,13 +245,15 @@ 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
|
||||
header = await decode_uvarint_from_stream(self.secured_conn)
|
||||
# TODO: Handle the case of EOF and other exceptions?
|
||||
try:
|
||||
header = await decode_uvarint_from_stream(self.secured_conn)
|
||||
except ParseError:
|
||||
return None, None, None
|
||||
try:
|
||||
message = await asyncio.wait_for(
|
||||
read_varint_prefixed_bytes(self.secured_conn), timeout=5
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
except (ParseError, IncompleteReadError, asyncio.TimeoutError):
|
||||
# TODO: Investigate what we should do if time is out.
|
||||
return None, None, None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user