Merge pull request #355 from NIC619/check_before_del
Check if entry exists in dictionary before delete
This commit is contained in:
commit
74198c70b1
|
@ -96,6 +96,7 @@ class MessageCache:
|
|||
last_entries: List[CacheEntry] = self.history[len(self.history) - 1]
|
||||
|
||||
for entry in last_entries:
|
||||
if entry.mid in self.msgs:
|
||||
del self.msgs[entry.mid]
|
||||
|
||||
i: int = len(self.history) - 2
|
||||
|
|
|
@ -297,6 +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]
|
||||
|
||||
async def _handle_reset(self, stream_id: StreamID) -> None:
|
||||
|
@ -315,6 +316,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]
|
||||
|
||||
async def _cleanup(self) -> None:
|
||||
|
|
|
@ -180,6 +180,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]
|
||||
|
||||
async def reset(self) -> None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user