From 02b3380ac345370fa615534bab167e8ead2c9aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 19 Oct 2022 21:40:33 +0200 Subject: [PATCH] Replace ensure_future calls with create_task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- ChangeLog | 1 + slixmpp_omemo/__init__.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1bcbe3..d67fcc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ Version xxx: 2022-xx-xx Maxime “pep” Buquet * Added: - Coroutines in asyncio.wait is now deprecated. Added create_task calls + - Replaced all ensure_future calls by create_task Version 0.8.0: 2022-08-23 Maxime “pep” Buquet * Breaking: diff --git a/slixmpp_omemo/__init__.py b/slixmpp_omemo/__init__.py index bca8094..1eb7b53 100644 --- a/slixmpp_omemo/__init__.py +++ b/slixmpp_omemo/__init__.py @@ -236,7 +236,7 @@ class XEP_0384(BasePlugin): "no data directory specified.") self._device_id = _load_device_id(self.data_dir) - asyncio.ensure_future(self.session_start_omemo()) + asyncio.create_task(self.session_start_omemo()) self.xmpp.add_event_handler('session_start', self.session_start) self.xmpp['xep_0060'].map_node_event(OMEMO_DEVICES_NS, 'omemo_device_list') @@ -245,7 +245,7 @@ class XEP_0384(BasePlugin): # If this plugin is loaded after 'session_start' has fired, we still # need to publish bundles if self.xmpp.is_connected and not self._initial_publish_done: - asyncio.ensure_future(self._initial_publish()) + asyncio.create_task(self._initial_publish()) def plugin_end(self): if not self.backend_loaded: @@ -469,7 +469,7 @@ class XEP_0384(BasePlugin): def _receive_device_list(self, msg: Message) -> None: """Handler for received PEP OMEMO_DEVICES_NS payloads""" - asyncio.ensure_future( + asyncio.create_task( self._read_device_list(msg['from'], msg['pubsub_event']['items']), ) @@ -755,7 +755,7 @@ class XEP_0384(BasePlugin): raise UntrustedException(exn.bare_jid, exn.device, exn.ik) raise finally: - asyncio.ensure_future(self._publish_bundle()) + asyncio.create_task(self._publish_bundle()) if self.auto_heartbeat: log.debug('Checking if heartbeat is required. auto_hearbeat enabled.')