From 869b11d322259c652b2a274901214ef3448d3797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 24 Aug 2019 00:14:41 +0200 Subject: [PATCH] Make session_start handler async and use asyncio helper in it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- slixmpp_omemo/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/slixmpp_omemo/__init__.py b/slixmpp_omemo/__init__.py index f313ab2..fd0586c 100644 --- a/slixmpp_omemo/__init__.py +++ b/slixmpp_omemo/__init__.py @@ -223,11 +223,13 @@ class XEP_0384(BasePlugin): self.xmpp.remove_event_handler('omemo_device_list_publish', self._receive_device_list) self.xmpp['xep_0163'].remove_interest(OMEMO_DEVICES_NS) - def session_start(self, _jid): + async def session_start(self, _jid): if self.backend_loaded: self.xmpp['xep_0163'].add_interest(OMEMO_DEVICES_NS) - asyncio.ensure_future(self._set_device_list()) - asyncio.ensure_future(self._publish_bundle()) + await asyncio.wait([ + self._set_device_list(), + self._publish_bundle(), + ]) def my_device_id(self) -> int: return self._device_id