Merge branch 'master' into feature/porting-to-trio

This commit is contained in:
mhchia
2019-12-24 02:19:43 +08:00
112 changed files with 3868 additions and 1946 deletions

View File

@ -292,8 +292,7 @@ class Mplex(IMuxedConn, Service):
# the entry of this stream, to avoid others from accessing it.
if is_local_closed:
async with self.streams_lock:
if stream_id in self.streams:
del self.streams[stream_id]
self.streams.pop(stream_id, None)
async def _handle_reset(self, stream_id: StreamID) -> None:
async with self.streams_lock:
@ -311,9 +310,8 @@ class Mplex(IMuxedConn, Service):
if not stream.event_local_closed.is_set():
stream.event_local_closed.set()
async with self.streams_lock:
if stream_id in self.streams:
del self.streams[stream_id]
del self.streams_msg_channels[stream_id]
self.streams.pop(stream_id, None)
self.streams_msg_channels.pop(stream_id, None)
async def _cleanup(self) -> None:
if not self.event_shutting_down.is_set():

View File

@ -170,8 +170,7 @@ class MplexStream(IMuxedStream):
if _is_remote_closed:
# Both sides are closed, we can safely remove the buffer from the dict.
async with self.muxed_conn.streams_lock:
if self.stream_id in self.muxed_conn.streams:
del self.muxed_conn.streams[self.stream_id]
self.muxed_conn.streams.pop(self.stream_id, None)
async def reset(self) -> None:
"""closes both ends of the stream tells this remote side to hang up."""
@ -199,11 +198,8 @@ class MplexStream(IMuxedStream):
await self.incoming_data_channel.aclose()
async with self.muxed_conn.streams_lock:
if (
self.muxed_conn.streams is not None
and self.stream_id in self.muxed_conn.streams
):
del self.muxed_conn.streams[self.stream_id]
if self.muxed_conn.streams is not None:
self.muxed_conn.streams.pop(self.stream_id, None)
# TODO deadline not in use
def set_deadline(self, ttl: int) -> bool: