summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-01-23 15:41:13 +0100
committermathieui <mathieui@mathieui.net>2021-01-28 17:54:40 +0100
commit0eed84d0b2fe144850a082feb339187bd98a4817 (patch)
tree7b14cc3b3d456262923c5d2865a00dce1b79a929
parent370abb1d983bf1aabff523d4bbc5c9b89a2becb8 (diff)
downloadslixmpp-0eed84d0b2fe144850a082feb339187bd98a4817.tar.gz
slixmpp-0eed84d0b2fe144850a082feb339187bd98a4817.tar.bz2
slixmpp-0eed84d0b2fe144850a082feb339187bd98a4817.tar.xz
slixmpp-0eed84d0b2fe144850a082feb339187bd98a4817.zip
xmlstream: handle done tasks in wait_until
and handle other loops properly
-rw-r--r--slixmpp/xmlstream/xmlstream.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index 6b890729..c8f797ac 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -1142,9 +1142,15 @@ class XMLStream(asyncio.BaseProtocol):
:param int timeout: Timeout
"""
fut = asyncio.Future()
+ def result_handler(event_data):
+ if not fut.done():
+ fut.set_result(event_data)
+ else:
+ log.debug("Future registered on event '%s' was alredy done", event)
+
self.add_event_handler(
event,
- fut.set_result,
+ result_handler,
disposable=True,
)
- return await asyncio.wait_for(fut, timeout)
+ return await asyncio.wait_for(fut, timeout, loop=self.loop)