Функция 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
High hope for another #Arbitrum hype still exists? Because we detect 2 whales that have just accumulated large amounts of $ARB:
✅ Whale 0x6b72 swapped 1.01M $USDT for 607,352 $ARB 4 hours ago. Average price: $1.66
✅ Whale 0x0610 accumulated a total of 2.332M $ARB over the past 2 days. Average price: $1.68
👉 More details: https://twitter.com/spotonchain/status/1648532794103177217
JUST IN :Robinhood launches #Arbitrum based blockchain and tokenized stock trading for European users, offering 24/5 access to over 200 U.S. 🇺🇸 stocks and ETFs.
@spherecryptoofficial1
🚨🚨2,693,961,178 $ARB (~$3.72B) were moved out of #Arbitrum vesting wallet 0x148440 and distributed to 145 addresses.
Address 0x7ff89e received the most at 72,428,835 $ARB ($99.95M), now the 8th largest holder.
The distribution process took place via middle wallet 0x1e7016. 4.17M $ARB (~$5.76M) remained undistributed in it.
Addresses
- Team ARB vesting contract: 0x148440E028565Db5f790fA3fbdbBcF0402A6a289
- Middle wallet: 0x1e7016f7c23859d097668c27b72c170ed7129a10
- Wallet the received the most: 0x7ff89e3c139a30fea7f0d0b079e0d17b95267137
This smart trader, who used to earn $671.6K from trading $GRAIL, started to touch on other #Arbitrum tokens:
- 306.6K $JOE purchased at $0.59 (~$180K). Now staked and worth ~$195K.
- 3.16M$RDNT amassed at $0.4 ($1.27M) from Mar 21-23. Now worth ~ $1.2M
He once earned x2 his investment in $GRAIL by:
✅ Neatly accumulating 342 $GRAIL at only $1,815 (~$621.4K) during market downtime
✅ Sold all $GRAIL at an impressive price of $3,777 on Mar 22 when $GRAIL price surged due to the #Arbitrum airdrop
👉 More details: https://twitter.com/spotonchain/status/1641694153926144000
🚨🚨Arca has sold most of its #Arbitrum related tokens, maybe they are waiting for $ARB launch 🤔🤔
➡️ Swapped 1.6M $RDNT to 712.78K USDT (sell at $0.445 vs buy at $0.274) 10 hours ago
➡️ Swapped 312,000 $SYN for 165.62 $ETH (~$267K) (sell at $0.8 vs buy at $1.21) 4 hours ago
Currently, it clears all $DPX, $RDNT and still holds 20,198 $GMX ($1.6M) in staking and 548,779 $SYN ($510K) in two wallets
Addresses:
0xa66f8Db3B8F1e4c79e52ac89Fec052811F4dbd19
0x23a5efe19aa966388e132077d733672cf5798c03
🔥 VC Arca & traders seem to bet on #Arbitrum token $DPX too!
👉 Arca piled 1,881 $DPX from Feb 17 to 23 at $394 per $DPX (total cost $741.3K).
👉 Trader 0x2761 bought 1,867 $DPX on Mar 1 with 450 $ETH (~$741K) at $396.9 per $DPX. He once made $66.7K by trading $DPX before!
🎉Get ready for an exclusive $SBT Token airdrop!🌟
🤩 Suitbot is a trading bot operating on #ETH and #Arbitrum, aiming to simplify and enhance your DEFI experience.
We will be distributing 1 million tokens to our active community celebrating our token launch! 🫡
Is really easy to participate‼️
🤖 Use our bot to participate.
💬 Join our Telegram for details.
🔗 Telegram group: https://t.me/SuitBotPort
🔗 Twitter: https://twitter.com/SuitBot_TG
Don't miss out on this opportunity! 🚀
With the ongoing hype #Arbitrum narrative, $GMX has become 🔥 than ever before. Let us review some of the top $GMX activites lately!
1. Address 0x426fc1
❗️ Re-amassed 12K $GMX using 526 $ETH (~$994K) on Apr 06 (18hrs ago)
2. Address 0x297903
❗️ Amassed 4.5K $GMX since Mar 07 at $74.3 (~$335K); just got 1.2K $GMX from #Binance at $80.2 (~$100K) on Apr 05
💰 Current holding: 8.6K $GMX (~$677K)
3. Address 0xde32e5
❗️ Amassed 61K $GMX at $76.6 (~$4.7M) on Apr 05 in mid wallet 0xdf42be -> Staked all
💰 Holds 108.7K $GMX (~$8.7M) -> expected profit of $400K
👉 More details: https://twitter.com/spotonchain/status/1644213451001327616
🚀 Just dropped my special Variational Invite Code: OMNIGOLD
https://omni.variational.io/?ref=OMNIGOLD
Use it → get Silver tier on Omni for 90 days instantly (better points multiplier + loss refund odds)!
Zero-fee perps DEX on #Arbitrum. Farming $VAR #airdrop just got easier 🔥
Connect wallet & sign up now!
🪂#Airdrop event for #Arbitrum💙
🏃 First come first served 🏃
🏆 Airdrop Portal 👉https://arb-claim.kepler.homes?code=71D03A
💙 Invitation code: 71D03A
A total of 550,000 addresses are eligible for #airdrop and 5 types of AirDropbox with different scarcity can be issued.