SwarmConn: iterate streams.copy in _cleanup

To avoid `RuntimeError` if `streams` is changed.
This commit is contained in:
mhchia 2020-02-04 17:04:28 +08:00
parent d483982acb
commit 3fc60cb312
No known key found for this signature in database
GPG Key ID: 389EFBEA1362589A

View File

@ -46,7 +46,7 @@ class SwarmConn(INetConn):
# This is just for cleaning up state. The connection has already been closed. # This is just for cleaning up state. The connection has already been closed.
# We *could* optimize this but it really isn't worth it. # We *could* optimize this but it really isn't worth it.
for stream in self.streams: for stream in self.streams.copy():
await stream.reset() await stream.reset()
# Force context switch for stream handlers to process the stream reset event we just emit # Force context switch for stream handlers to process the stream reset event we just emit
# before we cancel the stream handler tasks. # before we cancel the stream handler tasks.