diff options
Diffstat (limited to 'slixmpp/plugins/xep_0047/stream.py')
-rw-r--r-- | slixmpp/plugins/xep_0047/stream.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/slixmpp/plugins/xep_0047/stream.py b/slixmpp/plugins/xep_0047/stream.py index f020ea68..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): @@ -115,7 +122,7 @@ class IBBytestream(object): self.xmpp.add_event_handler('ibb_stream_end', on_close) self.xmpp.add_event_handler('ibb_stream_data', on_data) try: - await asyncio.wait_for(end_future, timeout, loop=self.xmpp.loop) + await asyncio.wait_for(end_future, timeout) except asyncio.TimeoutError: raise IqTimeout(result) finally: |