summaryrefslogtreecommitdiff
path: root/slixmpp/xmlstream
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-12-05 17:37:50 +0100
committermathieui <mathieui@mathieui.net>2020-12-05 17:37:50 +0100
commit73cc2a40082cf936221adb09cfe208bd06cd4b60 (patch)
treeb6460caabba875c04bb5f680aa29954037b8ba09 /slixmpp/xmlstream
parentaa5d422f38889edf2131d840ca50e3fb8a603420 (diff)
parent77587a48432901b5a43441f3e41fe26c02aeb8ed (diff)
downloadslixmpp-73cc2a40082cf936221adb09cfe208bd06cd4b60.tar.gz
slixmpp-73cc2a40082cf936221adb09cfe208bd06cd4b60.tar.bz2
slixmpp-73cc2a40082cf936221adb09cfe208bd06cd4b60.tar.xz
slixmpp-73cc2a40082cf936221adb09cfe208bd06cd4b60.zip
Merge branch 'first-integration-tests' into 'master'
First integration tests See merge request poezio/slixmpp!75
Diffstat (limited to 'slixmpp/xmlstream')
-rw-r--r--slixmpp/xmlstream/xmlstream.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index af494903..066d84df 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -12,7 +12,7 @@
:license: MIT, see LICENSE for more details
"""
-from typing import Optional, Set, Callable
+from typing import Optional, Set, Callable, Any
import functools
import logging
@@ -1130,3 +1130,18 @@ class XMLStream(asyncio.BaseProtocol):
:param exception: An unhandled exception object.
"""
pass
+
+ async def wait_until(self, event: str, timeout=30) -> Any:
+ """Utility method to wake on the next firing of an event.
+ (Registers a disposable handler on it)
+
+ :param str event: Event to wait on.
+ :param int timeout: Timeout
+ """
+ fut = asyncio.Future()
+ self.add_event_handler(
+ event,
+ fut.set_result,
+ disposable=True,
+ )
+ return await asyncio.wait_for(fut, timeout)