From be6dde17f16e85b50361a3db243e9b2e40b2cb5d Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 13 Dec 2021 21:25:41 +0100 Subject: Revert "Replace asyncio.ensure_future() with asyncio.create_task()" This reverts commit bac6a4b2bf2fc98401e0de7168c4a5cf31b08b37. This is not actually something we want --- slixmpp/xmlstream/handler/coroutine_callback.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'slixmpp/xmlstream/handler') 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 -- cgit v1.2.3