Cancel other image task when one already finished on tg frontend ipfs image gather

pull/26/head
Guillermo Rodriguez 2023-10-08 10:27:25 -03:00
parent 16df97d731
commit cadd723191
No known key found for this signature in database
GPG Key ID: EC3AB66D5D83B392
1 changed files with 8 additions and 3 deletions

View File

@ -266,10 +266,15 @@ class SkynetTelegramFrontend:
logging.warning(f'couldn\'t get ipfs binary data at {link}!') logging.warning(f'couldn\'t get ipfs binary data at {link}!')
tasks = [ tasks = [
get_and_set_results(ipfs_link), asyncio.create_task(get_and_set_results(ipfs_link)),
get_and_set_results(ipfs_link_legacy) asyncio.create_task(get_and_set_results(ipfs_link_legacy))
] ]
await asyncio.gather(*tasks) done, pending = await asyncio.wait(
tasks, return_when=asyncio.FIRST_COMPLETED)
for task in pending:
task.cancel()
png_img = None png_img = None
if ipfs_link_legacy in results: if ipfs_link_legacy in results:
png_img = results[ipfs_link_legacy] png_img = results[ipfs_link_legacy]