Revert "Replace asyncio.ensure_future() with asyncio.create_task()"
This reverts commit bac6a4b2bf
.
This is not actually something we want
This commit is contained in:
parent
14ae84d666
commit
be6dde17f1
6 changed files with 16 additions and 16 deletions
|
@ -342,7 +342,7 @@ class XEP_0045(BasePlugin):
|
||||||
maxchars = 9
|
maxchars = 9
|
||||||
else:
|
else:
|
||||||
maxstanzas = int(maxhistory)
|
maxstanzas = int(maxhistory)
|
||||||
return asyncio.create_task(
|
return asyncio.ensure_future(
|
||||||
self.join_muc_wait(
|
self.join_muc_wait(
|
||||||
room=room,
|
room=room,
|
||||||
nick=nick,
|
nick=nick,
|
||||||
|
|
|
@ -61,7 +61,7 @@ class XEP_0163(BasePlugin):
|
||||||
for ns in namespace:
|
for ns in namespace:
|
||||||
self.xmpp['xep_0030'].add_feature('%s+notify' % ns,
|
self.xmpp['xep_0030'].add_feature('%s+notify' % ns,
|
||||||
jid=jid)
|
jid=jid)
|
||||||
asyncio.create_task(
|
asyncio.ensure_future(
|
||||||
self.xmpp['xep_0115'].update_caps(jid, broadcast=False),
|
self.xmpp['xep_0115'].update_caps(jid, broadcast=False),
|
||||||
loop=self.xmpp.loop,
|
loop=self.xmpp.loop,
|
||||||
)
|
)
|
||||||
|
@ -82,7 +82,7 @@ class XEP_0163(BasePlugin):
|
||||||
for ns in namespace:
|
for ns in namespace:
|
||||||
self.xmpp['xep_0030'].del_feature(jid=jid,
|
self.xmpp['xep_0030'].del_feature(jid=jid,
|
||||||
feature='%s+notify' % namespace)
|
feature='%s+notify' % namespace)
|
||||||
asyncio.create_task(
|
asyncio.ensure_future(
|
||||||
self.xmpp['xep_0115'].update_caps(jid, broadcast=False),
|
self.xmpp['xep_0115'].update_caps(jid, broadcast=False),
|
||||||
loop=self.xmpp.loop,
|
loop=self.xmpp.loop,
|
||||||
)
|
)
|
||||||
|
|
|
@ -118,7 +118,7 @@ class XEP_0199(BasePlugin):
|
||||||
tmp_futures.append(future)
|
tmp_futures.append(future)
|
||||||
self.__pending_futures = tmp_futures
|
self.__pending_futures = tmp_futures
|
||||||
|
|
||||||
future = asyncio.create_task(
|
future = asyncio.ensure_future(
|
||||||
self._keepalive(event),
|
self._keepalive(event),
|
||||||
loop=self.xmpp.loop,
|
loop=self.xmpp.loop,
|
||||||
)
|
)
|
||||||
|
|
|
@ -622,7 +622,7 @@ class SlixTest(unittest.TestCase):
|
||||||
|
|
||||||
def wait_for_send_queue(self):
|
def wait_for_send_queue(self):
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
future = asyncio.create_task(self.xmpp.run_filters(), loop=loop)
|
future = asyncio.ensure_future(self.xmpp.run_filters(), loop=loop)
|
||||||
queue = self.xmpp.waiting_queue
|
queue = self.xmpp.waiting_queue
|
||||||
loop.run_until_complete(queue.join())
|
loop.run_until_complete(queue.join())
|
||||||
future.cancel()
|
future.cancel()
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# :license: MIT, see LICENSE for more details
|
# :license: MIT, see LICENSE for more details
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
from asyncio import iscoroutinefunction, ensure_future
|
||||||
from typing import Optional, Callable, Awaitable, TYPE_CHECKING
|
from typing import Optional, Callable, Awaitable, TYPE_CHECKING
|
||||||
|
|
||||||
from slixmpp.xmlstream.stanzabase import StanzaBase
|
from slixmpp.xmlstream.stanzabase import StanzaBase
|
||||||
|
@ -52,7 +52,7 @@ class CoroutineCallback(BaseHandler):
|
||||||
pointer: CoroutineFunction, once: bool = False,
|
pointer: CoroutineFunction, once: bool = False,
|
||||||
instream: bool = False, stream: Optional[XMLStream] = None):
|
instream: bool = False, stream: Optional[XMLStream] = None):
|
||||||
BaseHandler.__init__(self, name, matcher, stream)
|
BaseHandler.__init__(self, name, matcher, stream)
|
||||||
if not asyncio.iscoroutinefunction(pointer):
|
if not iscoroutinefunction(pointer):
|
||||||
raise ValueError("Given function is not a coroutine")
|
raise ValueError("Given function is not a coroutine")
|
||||||
|
|
||||||
async def pointer_wrapper(stanza: StanzaBase) -> None:
|
async def pointer_wrapper(stanza: StanzaBase) -> None:
|
||||||
|
@ -87,7 +87,7 @@ class CoroutineCallback(BaseHandler):
|
||||||
:meth:`prerun()`. Defaults to ``False``.
|
:meth:`prerun()`. Defaults to ``False``.
|
||||||
"""
|
"""
|
||||||
if not self._instream or instream:
|
if not self._instream or instream:
|
||||||
asyncio.create_task(self._pointer(payload))
|
ensure_future(self._pointer(payload))
|
||||||
if self._once:
|
if self._once:
|
||||||
self._destroy = True
|
self._destroy = True
|
||||||
del self._pointer
|
del self._pointer
|
||||||
|
|
|
@ -415,7 +415,7 @@ class XMLStream(asyncio.BaseProtocol):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if self._run_out_filters is None or self._run_out_filters.done():
|
if self._run_out_filters is None or self._run_out_filters.done():
|
||||||
self._run_out_filters = asyncio.create_task(
|
self._run_out_filters = asyncio.ensure_future(
|
||||||
self.run_filters(),
|
self.run_filters(),
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
)
|
)
|
||||||
|
@ -439,7 +439,7 @@ class XMLStream(asyncio.BaseProtocol):
|
||||||
self.disable_starttls = disable_starttls
|
self.disable_starttls = disable_starttls
|
||||||
|
|
||||||
self.event("connecting")
|
self.event("connecting")
|
||||||
self._current_connection_attempt = asyncio.create_task(
|
self._current_connection_attempt = asyncio.ensure_future(
|
||||||
self._connect_routine(),
|
self._connect_routine(),
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
)
|
)
|
||||||
|
@ -486,7 +486,7 @@ class XMLStream(asyncio.BaseProtocol):
|
||||||
if self._current_connection_attempt is None:
|
if self._current_connection_attempt is None:
|
||||||
return
|
return
|
||||||
self._connect_loop_wait = self._connect_loop_wait * 2 + 1
|
self._connect_loop_wait = self._connect_loop_wait * 2 + 1
|
||||||
self._current_connection_attempt = asyncio.create_task(
|
self._current_connection_attempt = asyncio.ensure_future(
|
||||||
self._connect_routine(),
|
self._connect_routine(),
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
)
|
)
|
||||||
|
@ -653,12 +653,12 @@ class XMLStream(asyncio.BaseProtocol):
|
||||||
self.disconnect_reason = reason
|
self.disconnect_reason = reason
|
||||||
if self.waiting_queue.empty() or ignore_send_queue:
|
if self.waiting_queue.empty() or ignore_send_queue:
|
||||||
self.cancel_connection_attempt()
|
self.cancel_connection_attempt()
|
||||||
return asyncio.create_task(
|
return asyncio.ensure_future(
|
||||||
self._end_stream_wait(wait, reason=reason),
|
self._end_stream_wait(wait, reason=reason),
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return asyncio.create_task(
|
return asyncio.ensure_future(
|
||||||
self._consume_send_queue_before_disconnecting(reason, wait),
|
self._consume_send_queue_before_disconnecting(reason, wait),
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
)
|
)
|
||||||
|
@ -1058,7 +1058,7 @@ class XMLStream(asyncio.BaseProtocol):
|
||||||
old_exception(e)
|
old_exception(e)
|
||||||
else:
|
else:
|
||||||
self.exception(e)
|
self.exception(e)
|
||||||
asyncio.create_task(
|
asyncio.ensure_future(
|
||||||
handler_callback_routine(handler_callback),
|
handler_callback_routine(handler_callback),
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
)
|
)
|
||||||
|
@ -1224,7 +1224,7 @@ class XMLStream(asyncio.BaseProtocol):
|
||||||
)
|
)
|
||||||
if pending:
|
if pending:
|
||||||
self.__slow_tasks.append(task)
|
self.__slow_tasks.append(task)
|
||||||
asyncio.create_task(
|
asyncio.ensure_future(
|
||||||
self._continue_slow_send(
|
self._continue_slow_send(
|
||||||
task,
|
task,
|
||||||
already_run_filters
|
already_run_filters
|
||||||
|
@ -1431,7 +1431,7 @@ class XMLStream(asyncio.BaseProtocol):
|
||||||
|
|
||||||
:param coroutine: The coroutine to wrap.
|
:param coroutine: The coroutine to wrap.
|
||||||
"""
|
"""
|
||||||
return asyncio.create_task(
|
return asyncio.ensure_future(
|
||||||
coroutine,
|
coroutine,
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue