add some additional logging

This commit is contained in:
Alex Stokes 2019-11-07 20:57:43 -08:00
parent 9c05e2b0bb
commit 4b01c33d54
No known key found for this signature in database
GPG Key ID: 51CE1721B245C086
2 changed files with 10 additions and 2 deletions

View File

@ -168,7 +168,11 @@ class BasicHost(IHost):
protocol, handler = await self.multiselect.negotiate( protocol, handler = await self.multiselect.negotiate(
MultiselectCommunicator(net_stream) 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() await net_stream.reset()
return return
net_stream.set_protocol(protocol) net_stream.set_protocol(protocol)

View File

@ -1,4 +1,5 @@
import asyncio import asyncio
import logging
from typing import Any # noqa: F401 from typing import Any # noqa: F401
from typing import Awaitable, Dict, List, Optional, Tuple 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") MPLEX_PROTOCOL_ID = TProtocol("/mplex/6.7.0")
logger = logging.getLogger("libp2p.stream_muxer.mplex.mplex")
class Mplex(IMuxedConn): class Mplex(IMuxedConn):
""" """
@ -181,7 +184,8 @@ class Mplex(IMuxedConn):
while True: while True:
try: try:
await self._handle_incoming_message() await self._handle_incoming_message()
except MplexUnavailable: except MplexUnavailable as e:
logger.debug("mplex unavailable while waiting for incoming: %s", e)
break break
# Force context switch # Force context switch
await asyncio.sleep(0) await asyncio.sleep(0)