SwarmConn: don't catch exceptions in handler

This commit is contained in:
mhchia 2020-02-04 15:10:49 +08:00
parent 5da102d1c9
commit d483982acb
No known key found for this signature in database
GPG Key ID: 389EFBEA1362589A

View File

@ -20,7 +20,6 @@ class SwarmConn(INetConn):
muxed_conn: IMuxedConn
swarm: "Swarm"
streams: Set[NetStream]
event_started: trio.Event
event_closed: trio.Event
def __init__(self, muxed_conn: IMuxedConn, swarm: "Swarm") -> None:
@ -72,10 +71,7 @@ class SwarmConn(INetConn):
if self.swarm.common_stream_handler is not None:
try:
await self.swarm.common_stream_handler(net_stream)
# TODO: More exact exceptions
except Exception:
# TODO: Emit logs.
# TODO: Clean up and remove the stream from SwarmConn if there is anything wrong.
finally:
self.remove_stream(net_stream)
def _add_stream(self, muxed_stream: IMuxedStream) -> NetStream: