Skip to content

Commit ef3189d

Browse files
moodyjoneukreign
authored andcommitted
Work on some DeprecationWarnings: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8.
1 parent c2d2080 commit ef3189d

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

lbry/blob_exchange/downloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def request_blob_from_peer(self, blob: 'AbstractBlob', peer: 'KademliaPeer
6464
self.scores[peer] = bytes_received / elapsed if bytes_received and elapsed else 1
6565

6666
async def new_peer_or_finished(self):
67-
active_tasks = list(self.active_connections.values()) + [asyncio.sleep(1)]
67+
active_tasks = list(self.active_connections.values()) + [asyncio.create_task(asyncio.sleep(1))]
6868
await asyncio.wait(active_tasks, return_when='FIRST_COMPLETED')
6969

7070
def cleanup_active(self):

lbry/extras/daemon/componentmanager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async def start(self):
118118
component._setup() for component in stage if not component.running
119119
]
120120
if needing_start:
121-
await asyncio.wait(needing_start)
121+
await asyncio.wait(map(asyncio.create_task, needing_start))
122122
self.started.set()
123123

124124
async def stop(self):
@@ -131,7 +131,7 @@ async def stop(self):
131131
component._stop() for component in stage if component.running
132132
]
133133
if needing_stop:
134-
await asyncio.wait(needing_stop)
134+
await asyncio.wait(map(asyncio.create_task, needing_stop))
135135

136136
def all_components_running(self, *component_names):
137137
"""

lbry/extras/daemon/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ def _save_claims(transaction):
793793

794794
await self.db.run(_save_claims)
795795
if update_file_callbacks:
796-
await asyncio.wait(update_file_callbacks)
796+
await asyncio.wait(map(asyncio.create_task, update_file_callbacks))
797797
if claim_id_to_supports:
798798
await self.save_supports(claim_id_to_supports)
799799

lbry/wallet/ledger.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,10 @@ def get_root_of_merkle_tree(branches, branch_positions, working_branch):
329329
async def start(self):
330330
if not os.path.exists(self.path):
331331
os.mkdir(self.path)
332-
await asyncio.wait([
332+
await asyncio.wait(map(asyncio.create_task, [
333333
self.db.open(),
334334
self.headers.open()
335-
])
335+
]))
336336
fully_synced = self.on_ready.first
337337
asyncio.create_task(self.network.start())
338338
await self.network.on_connected.first
@@ -466,9 +466,9 @@ async def receive_header(self, response):
466466
async def subscribe_accounts(self):
467467
if self.network.is_connected and self.accounts:
468468
log.info("Subscribe to %i accounts", len(self.accounts))
469-
await asyncio.wait([
469+
await asyncio.wait(map(asyncio.create_task, [
470470
self.subscribe_account(a) for a in self.accounts
471-
])
471+
]))
472472

473473
async def subscribe_account(self, account: Account):
474474
for address_manager in account.address_managers.values():

lbry/wallet/network.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ async def network_loop(self):
312312
sleep_delay = 30
313313
while self.running:
314314
await asyncio.wait(
315-
[asyncio.sleep(30), self._urgent_need_reconnect.wait()], return_when=asyncio.FIRST_COMPLETED
315+
map(asyncio.create_task, [asyncio.sleep(30), self._urgent_need_reconnect.wait()]),
316+
return_when=asyncio.FIRST_COMPLETED
316317
)
317318
if self._urgent_need_reconnect.is_set():
318319
sleep_delay = 30
@@ -338,7 +339,7 @@ async def network_loop(self):
338339
try:
339340
if not self._urgent_need_reconnect.is_set():
340341
await asyncio.wait(
341-
[self._keepalive_task, self._urgent_need_reconnect.wait()],
342+
[self._keepalive_task, asyncio.create_task(self._urgent_need_reconnect.wait())],
342343
return_when=asyncio.FIRST_COMPLETED
343344
)
344345
else:

0 commit comments

Comments
 (0)