From d4f98fb929a505fb88f9f6ccddb244515abca24c Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Fri, 29 Jul 2022 15:07:13 -0400 Subject: [PATCH] Work on some DeprecationWarnings: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8. --- lbry/blob_exchange/downloader.py | 2 +- lbry/extras/daemon/componentmanager.py | 4 ++-- lbry/extras/daemon/storage.py | 2 +- lbry/wallet/ledger.py | 8 ++++---- lbry/wallet/network.py | 5 +++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lbry/blob_exchange/downloader.py b/lbry/blob_exchange/downloader.py index 6ba62c402..23085b777 100644 --- a/lbry/blob_exchange/downloader.py +++ b/lbry/blob_exchange/downloader.py @@ -64,7 +64,7 @@ class BlobDownloader: self.scores[peer] = bytes_received / elapsed if bytes_received and elapsed else 1 async def new_peer_or_finished(self): - active_tasks = list(self.active_connections.values()) + [asyncio.sleep(1)] + active_tasks = list(self.active_connections.values()) + [asyncio.create_task(asyncio.sleep(1))] await asyncio.wait(active_tasks, return_when='FIRST_COMPLETED') def cleanup_active(self): diff --git a/lbry/extras/daemon/componentmanager.py b/lbry/extras/daemon/componentmanager.py index 82b2d6db3..5eb8a5ab3 100644 --- a/lbry/extras/daemon/componentmanager.py +++ b/lbry/extras/daemon/componentmanager.py @@ -118,7 +118,7 @@ class ComponentManager: component._setup() for component in stage if not component.running ] if needing_start: - await asyncio.wait(needing_start) + await asyncio.wait(map(asyncio.create_task, needing_start)) self.started.set() async def stop(self): @@ -131,7 +131,7 @@ class ComponentManager: component._stop() for component in stage if component.running ] if needing_stop: - await asyncio.wait(needing_stop) + await asyncio.wait(map(asyncio.create_task, needing_stop)) def all_components_running(self, *component_names): """ diff --git a/lbry/extras/daemon/storage.py b/lbry/extras/daemon/storage.py index 81b4263dc..ff1cbb6f5 100644 --- a/lbry/extras/daemon/storage.py +++ b/lbry/extras/daemon/storage.py @@ -793,7 +793,7 @@ class SQLiteStorage(SQLiteMixin): await self.db.run(_save_claims) if update_file_callbacks: - await asyncio.wait(update_file_callbacks) + await asyncio.wait(map(asyncio.create_task, update_file_callbacks)) if claim_id_to_supports: await self.save_supports(claim_id_to_supports) diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index 477c19f9c..88bee190e 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -329,10 +329,10 @@ class Ledger(metaclass=LedgerRegistry): async def start(self): if not os.path.exists(self.path): os.mkdir(self.path) - await asyncio.wait([ + await asyncio.wait(map(asyncio.create_task, [ self.db.open(), self.headers.open() - ]) + ])) fully_synced = self.on_ready.first asyncio.create_task(self.network.start()) await self.network.on_connected.first @@ -466,9 +466,9 @@ class Ledger(metaclass=LedgerRegistry): async def subscribe_accounts(self): if self.network.is_connected and self.accounts: log.info("Subscribe to %i accounts", len(self.accounts)) - await asyncio.wait([ + await asyncio.wait(map(asyncio.create_task, [ self.subscribe_account(a) for a in self.accounts - ]) + ])) async def subscribe_account(self, account: Account): for address_manager in account.address_managers.values(): diff --git a/lbry/wallet/network.py b/lbry/wallet/network.py index bd7a3fdbd..ed3889200 100644 --- a/lbry/wallet/network.py +++ b/lbry/wallet/network.py @@ -312,7 +312,8 @@ class Network: sleep_delay = 30 while self.running: await asyncio.wait( - [asyncio.sleep(30), self._urgent_need_reconnect.wait()], return_when=asyncio.FIRST_COMPLETED + map(asyncio.create_task, [asyncio.sleep(30), self._urgent_need_reconnect.wait()]), + return_when=asyncio.FIRST_COMPLETED ) if self._urgent_need_reconnect.is_set(): sleep_delay = 30 @@ -338,7 +339,7 @@ class Network: try: if not self._urgent_need_reconnect.is_set(): await asyncio.wait( - [self._keepalive_task, self._urgent_need_reconnect.wait()], + [self._keepalive_task, asyncio.create_task(self._urgent_need_reconnect.wait())], return_when=asyncio.FIRST_COMPLETED ) else: