summaryrefslogtreecommitdiff
path: root/slixmpp/xmlstream/handler/coroutine_callback.py
diff options
context:
space:
mode:
Diffstat (limited to 'slixmpp/xmlstream/handler/coroutine_callback.py')
-rw-r--r--slixmpp/xmlstream/handler/coroutine_callback.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/slixmpp/xmlstream/handler/coroutine_callback.py b/slixmpp/xmlstream/handler/coroutine_callback.py
index 1ebe3ae4..524cca54 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
-import asyncio
+from asyncio import iscoroutinefunction, ensure_future
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 asyncio.iscoroutinefunction(pointer):
+ if not 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:
- asyncio.create_task(self._pointer(payload))
+ ensure_future(self._pointer(payload))
if self._once:
self._destroy = True
del self._pointer