SwarmConn: perform close
right away
In `_handle_new_streams`, when the underlying muxed conn is unavailable, close `SwarmConn` itself right away, to reset all the streams. Therefore, the stream processed by `_handle_muxed_stream` are conscious of the fact that they are reset. It allows a more graceful clean up.
This commit is contained in:
parent
c0ab609559
commit
13930ae718
|
@ -61,12 +61,11 @@ class SwarmConn(INetConn):
|
|||
try:
|
||||
stream = await self.muxed_conn.accept_stream()
|
||||
except MuxedConnUnavailable:
|
||||
await self.close()
|
||||
break
|
||||
# Asynchronously handle the accepted stream, to avoid blocking the next stream.
|
||||
nursery.start_soon(self._handle_muxed_stream, stream)
|
||||
|
||||
await self.close()
|
||||
|
||||
async def _handle_muxed_stream(self, muxed_stream: IMuxedStream) -> None:
|
||||
net_stream = self._add_stream(muxed_stream)
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user