fix: specific cases in xep-0047 with network race conditions

This commit is contained in:
mathieui 2022-02-04 18:18:39 +01:00
parent 714f9aae0d
commit e543e22e78

View file

@ -99,6 +99,13 @@ class IBBytestream(object):
:returns: All bytes accumulated in the stream. :returns: All bytes accumulated in the stream.
""" """
result = b'' 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() end_future = asyncio.Future()
def on_close(stream): def on_close(stream):