Add test for Swarm.close_peer

This commit is contained in:
mhchia
2019-09-14 23:37:01 +08:00
parent 6923f257f6
commit e7304538da
6 changed files with 130 additions and 29 deletions

View File

@ -50,11 +50,12 @@ class SwarmConn(INetConn):
task.cancel()
async def _handle_new_streams(self) -> None:
# TODO: Break the loop when anything wrong in the connection.
while True:
try:
stream = await self.conn.accept_stream()
except MuxedConnUnavailable:
# If there is anything wrong in the MuxedConn,
# we should break the loop and close the connection.
break
# Asynchronously handle the accepted stream, to avoid blocking the next stream.
await self.run_task(self._handle_muxed_stream(stream))