Функция asyncio.wait() это еще один способ вызвать множество асинхронных задач.
Она работает в нескольких режимах.
1. Самый простой - ждем завершения всех задач
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(10)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.ALL_COMPLETED
)
for task in done:
try:
print(task.result())
except Exception as e:
print(e)
Очень похоже на gather, но работает не так.
▫️возвращает не результаты, а два сета с объектами Task у которых можно забрать результат через task.result() если они в списке done
▫️не гарантирует порядок результатов так как оба объекта это set
▫️не выбрасывает исключение когда оно появляется, а сохраняет его в Task. Исключение появится когда попробуете забрать резултьтат.
2. Ждем завершения первой задачи, даже если там ошибка.
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(3)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_COMPLETED
)
# в done может быть несколько задач!
for task in done:
try:
print(task.result())
except Exception as e:
print(f"Fail: {e}")
# Оставшиеся задачи в pending, как правило, нужно отменить, иначе они будут продолжать работать
for task in pending:
task.cancel()
В сете done будут таски которые успели завершится, причем как успешно так и нет.
3. До первой ошибки.
Тоже самое, но с аргументом FIRST_EXCEPTION
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_EXCEPTION
)
Функция завершается как только первая задача упадет с ошибкой.
Учтите, что в любом случае done вы можете обранужить несколько задач, как с ошибками так и успешные.
↗️ Полный листинг примеров здесь
#async
⚖️ Основатели проекта Dropil (DROP) Джереми Макалпин и Захари Матар согласились признать вину в мошенничестве с ICO на сумму почти $1,9 млн
Их обвинили в «серии ложных заявлений инвесторам» для «продвижения успеха криптовалюты». По данным Министерства юстиции США, основатели Dropil выплатили себе и партнерам как минимум $1,6 млн из привлеченных средств.
#ICO
Bought for $15.5k, sold for $122 million
#ETH holder purchased 50k$ETH at #ICO for $15.5k 9 years ago, and today he has 10 thousand coins ($24.37 million) on Kraken. In total, his coins are now valued at $122 million.
I waited for my chance🔥🔥🔥
💸Blockchain ICOs
This artist finally made me realize why all my money seem to vanish over time...
#Blockchain#ICO
🚀@PerspectiveIX via Reddit/u/nichlaes.
❓Have you invested in any ICOs?
An #Ethereum#ICO participant returned to sell 2,000 $ETH for 6M $USDC at $2,997 6 hours ago.
Notably, the whale received 33,213 $ETH at #Ethereum Genesis on Jul 30, 2015, at an ICO price of ~$0.31. So far, 5,110 $ETH has been deposited to #Kraken or sold via DEX at ~$2,545.
Currently, the whale still holds around 29.7K $ETH ($89.4M) across 3 wallets, mostly within staking platforms.
Follow @spotonchain and set alerts for the addresses of the ETH ICO participant via this entity now: https://platform.spotonchain.ai/en/entity/2098
An #Ethereum#ICO participant just woke up after 8.7 years of dormancy and transferred all 2,000 $ETH ($6.71M) to several new wallets!
The whale received 2,000 $ETH at #Ethereum Genesis on Jul 30, 2015, at the ETH ICO price of ~$0.31.
So far, 25 $ETH ($84.1K) has been deposited to #ChangeNOW at ~ $3,363.
Token flow: https://platform.spotonchain.com/en/visualizer?id=87887&thresholdOption=4
Follow @spotonchain and set alerts for the addresses of the $ETH ICO participant now!
An #Ethereum#ICO participant returned after 1.12 years to deposit 1,069 $ETH ($3.56M) to #Kraken at $3,329 3 hours ago.
The whale received 12,566 $ETH at #Ethereum Genesis in Jul 2015, at an ICO price of ~$0.31,
And then distributed the $ETH across 12 wallets in 2017, of which 4,847 $ETH have been deposited to #Kraken and #Gemini at ~$1,637.
Now still holds 7,719 $ETH ($25.7M) across 8 wallets.
Token flow: https://platform.spotonchain.ai/en/visualizer?id=99906
Follow @spotonchain and set alerts for the addresses of the $ETH ICO participant now!
🦄🦄Telegram is raising $1.7 billion in funding - and they're not even done!
#Telegram raised $850 million from 94 investors in March in addition to $850 million it gained in February. That's almost two whole unicorns in the largest #ICO (Initial Coin Offering) to date.
The company, founded by self-exiled Russian Pavel Durov, plans to use the ICO proceeds to develop the Telegram Open Network #blockchain, which includes the cryptocurrency #Gram.
Interest in the Telegram ICO has recently helped the company surpass the threshold of 200 million monthly active users, “with over 700,000 new users signing up each day.”
🚀@PerspectiveIX
🌀 http://prs.pctvix.co/TelegramIX
UK Regulator Takes Action Against Snap Over AI Chatbot
Hello, everyone! The UK Information Commissioner's Office (ICO) has issued a preliminary enforcement notice to Snap, the parent company of Snapchat. This notice could compel Snap to halt the processing of data associated with its AI chatbot, "My AI," for UK users unless an adequate risk assessment is carried out.
The ICO's provisional investigation revealed that the initial risk assessment conducted before the launch of My AI did not sufficiently evaluate its data protection risks, especially concerning children. As a result, Snap may be required to suspend its My AI product in the UK until these concerns are addressed.
#Snap#AI#DataProtection#ICO#UKRegulation