Skip to content

Commit

Permalink
Work on some DeprecationWarnings: The explicit passing of coroutine o…
Browse files Browse the repository at this point in the history
…bjects to asyncio.wait() is deprecated since Python 3.8.
  • Loading branch information
moodyjon committed Jul 29, 2022
1 parent 7023fa7 commit e871881
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lbry/blob_exchange/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def request_blob_from_peer(self, blob: 'AbstractBlob', peer: 'KademliaPeer
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):
Expand Down
4 changes: 2 additions & 2 deletions lbry/extras/daemon/componentmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def start(self):
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):
Expand All @@ -131,7 +131,7 @@ async def stop(self):
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):
"""
Expand Down
2 changes: 1 addition & 1 deletion lbry/extras/daemon/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def _save_claims(transaction):

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)

Expand Down
8 changes: 4 additions & 4 deletions lbry/wallet/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ def get_root_of_merkle_tree(branches, branch_positions, working_branch):
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
Expand Down Expand Up @@ -466,9 +466,9 @@ async def receive_header(self, response):
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():
Expand Down
5 changes: 3 additions & 2 deletions lbry/wallet/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ async def network_loop(self):
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
Expand All @@ -341,7 +342,7 @@ async def network_loop(self):
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:
Expand Down

0 comments on commit e871881

Please sign in to comment.