From 79bbbdb3e633152cc95e77a550f2eb2cde4e6784 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 18 Nov 2021 15:23:46 +0100 Subject: Replace asyncio.ensure_future() with asyncio.create_task() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The latter function got introduced in Python 3.7, which is conveniently our MSPV, so let’s use that. --- plugins/exec.py | 2 +- plugins/irc.py | 2 +- plugins/ping.py | 6 +++--- plugins/upload.py | 2 +- plugins/user_extras.py | 9 +++------ plugins/vcard.py | 8 ++++---- 6 files changed, 13 insertions(+), 16 deletions(-) (limited to 'plugins') diff --git a/plugins/exec.py b/plugins/exec.py index 0786c86f..68f24486 100644 --- a/plugins/exec.py +++ b/plugins/exec.py @@ -95,4 +95,4 @@ class Plugin(BasePlugin): else: self.api.run_command('/help exec') return - asyncio.ensure_future(self.async_exec(command, arg)) + asyncio.create_task(self.async_exec(command, arg)) diff --git a/plugins/irc.py b/plugins/irc.py index a7650ec4..d732c127 100644 --- a/plugins/irc.py +++ b/plugins/irc.py @@ -141,7 +141,7 @@ from poezio import tabs class Plugin(BasePlugin): def init(self): if self.config.get('initial_connect', True): - asyncio.ensure_future( + asyncio.create_task( self.initial_connect() ) diff --git a/plugins/ping.py b/plugins/ping.py index 46ce4efc..cc987bf0 100644 --- a/plugins/ping.py +++ b/plugins/ping.py @@ -123,7 +123,7 @@ class Plugin(BasePlugin): jid = arg if not arg: jid = self.api.current_tab().jid - asyncio.ensure_future( + asyncio.create_task( self.command_ping(jid) ) @@ -140,7 +140,7 @@ class Plugin(BasePlugin): jid = JID(arg) except InvalidJID: return self.api.information('Invalid JID: %s' % arg, 'Error') - asyncio.ensure_future( + asyncio.create_task( self.command_ping(jid.full) ) @@ -156,7 +156,7 @@ class Plugin(BasePlugin): res = current.get_highest_priority_resource() if res is not None: jid =res.jid - asyncio.ensure_future( + asyncio.create_task( self.command_ping(jid) ) diff --git a/plugins/upload.py b/plugins/upload.py index c702dc49..9a70a965 100644 --- a/plugins/upload.py +++ b/plugins/upload.py @@ -78,7 +78,7 @@ class Plugin(BasePlugin): return filename, = args filename = expanduser(filename) - asyncio.ensure_future(self.send_upload(filename)) + asyncio.create_task(self.send_upload(filename)) @staticmethod def completion_filename(the_input): diff --git a/plugins/user_extras.py b/plugins/user_extras.py index ad49a142..96559111 100644 --- a/plugins/user_extras.py +++ b/plugins/user_extras.py @@ -91,10 +91,7 @@ Configuration """ -from asyncio import ( - ensure_future, - gather, -) +import asyncio from functools import reduce from typing import Dict @@ -174,10 +171,10 @@ class Plugin(BasePlugin): ] for name, handler in handlers: self.core.xmpp.del_event_handler(name, handler) - ensure_future(self._stop()) + asyncio.create_task(self._stop()) async def _stop(self): - await gather( + await asyncio.gather( self.core.xmpp.plugin['xep_0108'].stop(), self.core.xmpp.plugin['xep_0107'].stop(), self.core.xmpp.plugin['xep_0196'].stop(), diff --git a/plugins/vcard.py b/plugins/vcard.py index ef70dc79..b0c8e396 100644 --- a/plugins/vcard.py +++ b/plugins/vcard.py @@ -266,7 +266,7 @@ class Plugin(BasePlugin): self.api.information('Invalid JID: %s' % arg, 'Error') return - asyncio.ensure_future( + asyncio.create_task( self._get_vcard(jid) ) @@ -290,7 +290,7 @@ class Plugin(BasePlugin): jid = JID(arg) except InvalidJID: return self.api.information('Invalid JID: %s' % arg, 'Error') - asyncio.ensure_future( + asyncio.create_task( self._get_vcard(jid) ) @@ -301,11 +301,11 @@ class Plugin(BasePlugin): return current = self.api.current_tab().selected_row if isinstance(current, Resource): - asyncio.ensure_future( + asyncio.create_task( self._get_vcard(JID(current.jid).bare) ) elif isinstance(current, Contact): - asyncio.ensure_future( + asyncio.create_task( self._get_vcard(current.bare_jid) ) -- cgit v1.2.3