From e543e22e78241ad0cc3ee8704a9187a26eb08b60 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 4 Feb 2022 18:18:39 +0100 Subject: [PATCH] fix: specific cases in xep-0047 with network race conditions --- slixmpp/plugins/xep_0047/stream.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/slixmpp/plugins/xep_0047/stream.py b/slixmpp/plugins/xep_0047/stream.py index 0cda5dd9..29e70707 100644 --- a/slixmpp/plugins/xep_0047/stream.py +++ b/slixmpp/plugins/xep_0047/stream.py @@ -99,6 +99,13 @@ class IBBytestream(object): :returns: All bytes accumulated in the stream. """ result = b'' + while not self.recv_queue.empty(): + result += self.recv_queue.get_nowait() + if max_data and len(result) > max_data: + return result + if self.stream_in_closed: + return result + end_future = asyncio.Future() def on_close(stream):