Replace ensure_future calls with create_task

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2022-10-19 21:40:33 +02:00
parent fa3e690154
commit 02b3380ac3
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2
2 changed files with 5 additions and 4 deletions

View file

@ -2,6 +2,7 @@ Version xxx:
2022-xx-xx Maxime “pep” Buquet <pep@bouah.net> 2022-xx-xx Maxime “pep” Buquet <pep@bouah.net>
* Added: * Added:
- Coroutines in asyncio.wait is now deprecated. Added create_task calls - Coroutines in asyncio.wait is now deprecated. Added create_task calls
- Replaced all ensure_future calls by create_task
Version 0.8.0: Version 0.8.0:
2022-08-23 Maxime “pep” Buquet <pep@bouah.net> 2022-08-23 Maxime “pep” Buquet <pep@bouah.net>
* Breaking: * Breaking:

View file

@ -236,7 +236,7 @@ class XEP_0384(BasePlugin):
"no data directory specified.") "no data directory specified.")
self._device_id = _load_device_id(self.data_dir) 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.add_event_handler('session_start', self.session_start)
self.xmpp['xep_0060'].map_node_event(OMEMO_DEVICES_NS, 'omemo_device_list') 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 # If this plugin is loaded after 'session_start' has fired, we still
# need to publish bundles # need to publish bundles
if self.xmpp.is_connected and not self._initial_publish_done: 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): def plugin_end(self):
if not self.backend_loaded: if not self.backend_loaded:
@ -469,7 +469,7 @@ class XEP_0384(BasePlugin):
def _receive_device_list(self, msg: Message) -> None: def _receive_device_list(self, msg: Message) -> None:
"""Handler for received PEP OMEMO_DEVICES_NS payloads""" """Handler for received PEP OMEMO_DEVICES_NS payloads"""
asyncio.ensure_future( asyncio.create_task(
self._read_device_list(msg['from'], msg['pubsub_event']['items']), 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 UntrustedException(exn.bare_jid, exn.device, exn.ik)
raise raise
finally: finally:
asyncio.ensure_future(self._publish_bundle()) asyncio.create_task(self._publish_bundle())
if self.auto_heartbeat: if self.auto_heartbeat:
log.debug('Checking if heartbeat is required. auto_hearbeat enabled.') log.debug('Checking if heartbeat is required. auto_hearbeat enabled.')