Replace (check and) del pattern with pop method

This commit is contained in:
NIC619
2019-11-20 23:06:37 +08:00
parent 74198c70b1
commit 19907e18ec
8 changed files with 20 additions and 34 deletions

View File

@ -297,8 +297,7 @@ class Mplex(IMuxedConn):
# 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:
@ -316,8 +315,7 @@ class Mplex(IMuxedConn):
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]
self.streams.pop(stream_id, None)
async def _cleanup(self) -> None:
if not self.event_shutting_down.is_set():