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. --- poezio/tabs/basetabs.py | 8 ++++---- poezio/tabs/bookmarkstab.py | 2 +- poezio/tabs/muctab.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'poezio/tabs') diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index 508465e3..c2d9e93e 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -351,7 +351,7 @@ class Tab: if hasattr(self.input, "reset_completion"): self.input.reset_completion() if asyncio.iscoroutinefunction(func): - asyncio.ensure_future(func(arg)) + asyncio.create_task(func(arg)) else: func(arg) return True @@ -979,7 +979,7 @@ class ChatTab(Tab): def on_scroll_up(self): if not self.query_status: from poezio.log_loader import LogLoader - asyncio.ensure_future( + asyncio.create_task( LogLoader(logger, self, config.getbool('use_log')).scroll_requested() ) return self.text_win.scroll_up(self.text_win.height - 1) @@ -1036,10 +1036,10 @@ class OneToOneTab(ChatTab): if mam_filler.result == 0: self.handle_message(initial) - asyncio.ensure_future(fallback_no_mam()) + asyncio.create_task(fallback_no_mam()) elif use_log and initial: self.handle_message(initial, display=False) - asyncio.ensure_future( + asyncio.create_task( LogLoader(logger, self, use_log).tab_open() ) diff --git a/poezio/tabs/bookmarkstab.py b/poezio/tabs/bookmarkstab.py index 10c7c0ce..d21b5630 100644 --- a/poezio/tabs/bookmarkstab.py +++ b/poezio/tabs/bookmarkstab.py @@ -96,7 +96,7 @@ class BookmarksTab(Tab): if bm in self.bookmarks: self.bookmarks.remove(bm) - asyncio.ensure_future( + asyncio.create_task( self.save_routine() ) diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index acc145af..8acb9773 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -154,14 +154,14 @@ class MucTab(ChatTab): """ The user do not want to send their config, send an iq cancel """ - asyncio.ensure_future(self.core.xmpp['xep_0045'].cancel_config(self.jid)) + asyncio.create_task(self.core.xmpp['xep_0045'].cancel_config(self.jid)) self.core.close_tab() def send_config(self, form: Form) -> None: """ The user sends their config to the server """ - asyncio.ensure_future(self.core.xmpp['xep_0045'].set_room_config(self.jid, form)) + asyncio.create_task(self.core.xmpp['xep_0045'].set_room_config(self.jid, form)) self.core.close_tab() def join(self) -> None: @@ -610,7 +610,7 @@ class MucTab(ChatTab): }, ), ) - asyncio.ensure_future(LogLoader( + asyncio.create_task(LogLoader( logger, self, config.get_by_tabname('use_log', self.general_jid) ).tab_open()) @@ -1513,7 +1513,7 @@ class MucTab(ChatTab): bookmark = self.core.bookmarks[self.jid] if bookmark: bookmark.autojoin = False - asyncio.ensure_future( + asyncio.create_task( self.core.bookmarks.save(self.core.xmpp) ) self.core.close_tab(self) -- cgit v1.2.3