From 4b01c33d54d88c1d8e9e8e5247b0c97b1d45ab15 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Thu, 7 Nov 2019 20:57:43 -0800 Subject: [PATCH] add some additional logging --- libp2p/host/basic_host.py | 6 +++++- libp2p/stream_muxer/mplex/mplex.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libp2p/host/basic_host.py b/libp2p/host/basic_host.py index d12d6721..7469d33c 100644 --- a/libp2p/host/basic_host.py +++ b/libp2p/host/basic_host.py @@ -168,7 +168,11 @@ class BasicHost(IHost): protocol, handler = await self.multiselect.negotiate( MultiselectCommunicator(net_stream) ) - except MultiselectError: + except MultiselectError as error: + peer_id = net_stream.muxed_conn.peer_id + logger.debug( + "failed to accept a stream from peer %s, error=%s", peer_id, error + ) await net_stream.reset() return net_stream.set_protocol(protocol) diff --git a/libp2p/stream_muxer/mplex/mplex.py b/libp2p/stream_muxer/mplex/mplex.py index c8d7a209..2228360c 100644 --- a/libp2p/stream_muxer/mplex/mplex.py +++ b/libp2p/stream_muxer/mplex/mplex.py @@ -1,4 +1,5 @@ import asyncio +import logging from typing import Any # noqa: F401 from typing import Awaitable, Dict, List, Optional, Tuple @@ -23,6 +24,8 @@ from .mplex_stream import MplexStream MPLEX_PROTOCOL_ID = TProtocol("/mplex/6.7.0") +logger = logging.getLogger("libp2p.stream_muxer.mplex.mplex") + class Mplex(IMuxedConn): """ @@ -181,7 +184,8 @@ class Mplex(IMuxedConn): while True: try: await self._handle_incoming_message() - except MplexUnavailable: + except MplexUnavailable as e: + logger.debug("mplex unavailable while waiting for incoming: %s", e) break # Force context switch await asyncio.sleep(0)