diff options
author | mathieui <mathieui@mathieui.net> | 2021-12-13 20:40:15 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-12-13 20:40:15 +0100 |
commit | 0cc1095ffc5036f1f5eb8bd3773827d7a60ee04c (patch) | |
tree | 5c617870f7d431cd377bfaf8ae8bcde9a52f8859 /slixmpp/xmlstream/handler/coroutine_callback.py | |
parent | d4067275ff0eb646afaac2b0cbc9f351349ba9c0 (diff) | |
parent | bac6a4b2bf2fc98401e0de7168c4a5cf31b08b37 (diff) | |
download | slixmpp-0cc1095ffc5036f1f5eb8bd3773827d7a60ee04c.tar.gz slixmpp-0cc1095ffc5036f1f5eb8bd3773827d7a60ee04c.tar.bz2 slixmpp-0cc1095ffc5036f1f5eb8bd3773827d7a60ee04c.tar.xz slixmpp-0cc1095ffc5036f1f5eb8bd3773827d7a60ee04c.zip |
Merge branch 'asyncio-create-task' into 'master'
Replace asyncio.ensure_future() with asyncio.create_task()
See merge request poezio/slixmpp!169
Diffstat (limited to 'slixmpp/xmlstream/handler/coroutine_callback.py')
-rw-r--r-- | slixmpp/xmlstream/handler/coroutine_callback.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/slixmpp/xmlstream/handler/coroutine_callback.py b/slixmpp/xmlstream/handler/coroutine_callback.py index 524cca54..1ebe3ae4 100644 --- a/slixmpp/xmlstream/handler/coroutine_callback.py +++ b/slixmpp/xmlstream/handler/coroutine_callback.py @@ -6,7 +6,7 @@ # :license: MIT, see LICENSE for more details from __future__ import annotations -from asyncio import iscoroutinefunction, ensure_future +import asyncio from typing import Optional, Callable, Awaitable, TYPE_CHECKING from slixmpp.xmlstream.stanzabase import StanzaBase @@ -52,7 +52,7 @@ class CoroutineCallback(BaseHandler): pointer: CoroutineFunction, once: bool = False, instream: bool = False, stream: Optional[XMLStream] = None): BaseHandler.__init__(self, name, matcher, stream) - if not iscoroutinefunction(pointer): + if not asyncio.iscoroutinefunction(pointer): raise ValueError("Given function is not a coroutine") async def pointer_wrapper(stanza: StanzaBase) -> None: @@ -87,7 +87,7 @@ class CoroutineCallback(BaseHandler): :meth:`prerun()`. Defaults to ``False``. """ if not self._instream or instream: - ensure_future(self._pointer(payload)) + asyncio.create_task(self._pointer(payload)) if self._once: self._destroy = True del self._pointer |