summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-02-14 11:36:01 +0100
committermathieui <mathieui@mathieui.net>2021-02-26 00:08:56 +0100
commit8da5310ea61d40c3d31dc16f08846f4741c0c4f8 (patch)
tree9e02f47b4ac2888af73ce9d5857bfbe8ae599179
parent5f9ab45a5e161c3035a844184736b3180dae6047 (diff)
downloadslixmpp-8da5310ea61d40c3d31dc16f08846f4741c0c4f8.tar.gz
slixmpp-8da5310ea61d40c3d31dc16f08846f4741c0c4f8.tar.bz2
slixmpp-8da5310ea61d40c3d31dc16f08846f4741c0c4f8.tar.xz
slixmpp-8da5310ea61d40c3d31dc16f08846f4741c0c4f8.zip
xmlstream: add a wrap() method for ensure_future
-rw-r--r--slixmpp/xmlstream/xmlstream.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index 2f506018..02f4598c 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -9,6 +9,7 @@
# :license: MIT, see LICENSE for more details
from typing import (
Any,
+ Coroutine,
Callable,
Iterable,
Iterator,
@@ -1251,3 +1252,13 @@ class XMLStream(asyncio.BaseProtocol):
raise
finally:
self.del_event_handler(event, handler)
+
+ def wrap(self, coroutine: Coroutine[Any, Any, Any]) -> Future:
+ """Make a Future out of a coroutine with the current loop.
+
+ :param coroutine: The coroutine to wrap.
+ """
+ return asyncio.ensure_future(
+ coroutine,
+ loop=self.loop,
+ )