Функция 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
A whale deposited 2M $PIPPIN ($1.04M) into #MEXC, 16 hours ago, making a profit of $3.6M
The whale initially withdrew 7.56M $PIPPIN for $137K from #MEXC and still holds 2.03M $PIPPIN ($1.29M).
Address: Evee5RbYcc2Yhv6RajrA5epA9MCHuonAWu6dQYGPaC6f
https://x.com/OnchainLens/status/2022602547484332500
Follow @onchainlens for more onchain updates
#MEXC
Инвесторы массово выводят средства с биржи MEXC
Об этом предупреждает платформа CryptoQuant.
Ранее криптодетектив ZachXBT начал расследование касаемо возможного теневого владельца биржи MEXC по имени «Тони», личность которого якобы намеренно скрывается.
MEXC всегда была около-скамовой биржей. Наверное её решили добить конкуренты. Если держите средства на этой бирже, лучше вывести, на всякий случай.
Stake $USDT for 200% APR on MEXC!
The USDT Stake-to-Earn event is now live on #MEXC, your chance to grow your assets! Whether you’re just starting out or already an experienced trader, this is your moment to earn effortlessly.
🕰Event Period:
June 13, 2025, 10:00 (UTC) – July 13, 2025, 10:00 (UTC)
Event Details:
✅Exclusive to new users
✅Staking duration: 3 days
✅Estimated APR: 200%
✅Minimum individual stake: 100 $USDT
✅Maximum individual stake: 500 $USDT
📄Terms & Conditions available on the event page
📈Join MEXC via this link
🚨 Pre-market listing alert!
#MEXC will list $HOLD on the Pre-Market on Dec 7, 2024, at 8:00 (UTC). 🔥
Learn more: https://www.mexc.com/support/articles/17827791520305
🧐🧐 Two smart traders decided to sell their $LOOKS and hold $X2Y2 instead, is it a good strategy?
- One just moved all of his 7,3M $LOOKS ($1,9M) to #MEXC and keeps all of his $X2Y2
- Another just swapped 60% of his $LOOKS to $X2Y2
👉More details: https://twitter.com/spotonchain/status/1626976793076064257?s=20
⚡️TON Community: Exciting Opportunities During MEXC's TON Triumph Month
#TON#MEXC
TON Community announces the launch of the "TON Triumph" campaign on MEXC from May 21 to June 20, 2025. The campaign offers a $1,000,000 prize pool, zero trading fees, fee-free withdrawals, and various trading opportunities for Toncoin and USDe-TON users.
Source: link
@tonlines
#DYOR#MEXC
🚀Airdrop: LSVR by MEXC
💰Prize Pool: $800 Worth LSVR
🎁Winners: First 50 Users
🖥Distribution : After Event end
✅How to Claim 🚀Airdrop
🔹 Create a Account on Mexc Exchange Using this link
🔹 Deposit more than 100USD
🔹 Do trading of 500USD
🔹 You will receive 5000 LSVR(20USD) at Event end.
🔊Website: https://www.mexc.com
Disclaimer: Please do your own research before joining to any airdrops project. Don't send any fee or penny without doing Research.
🚨🚨 $LBR team (Lybra Finance) allegedly deposited 800K $LBR ($1.81M) to #OKX via 0x92d 7hrs ago, right before the CEX listed $LBR.
➡️ They also deposited another 50K $LBR ($118K) to #MEXC a day ago, via 0x5cc
⚠️ $LBR price has dropped 11.9% since the listing 2.5hrs ago.
👉 Visualizer: https://platform.spotonchain.ai/visualizer?id=1279
👉 Link to the full article: https://platform.spotonchain.ai/signal-details/lybra-finance-deposited-lbr-to-okx-right-before-listing-467
MEXC @MEXC_Official has supported the UXLINK Contract Swap.
Huge thanks for the swift action and continuous support to our community! 🙌
https://mexc.com/announcements/article/mexc-to-support-the-uxlink-uxlink-contract-swap-17827791530544
#Web3#UXLINK#MEXC
🔥🔥 Who managed to accumulate $MKR before the token hit its one-year high at $1,900 today?
Five fresh whales accumulated 23,891 $MKR ($38.1M) from #Binance, #Coinbase, and #MEXC at $1,593 on avg in the past 10 days leading the pump.
Their joint floating gain is $5.28M (+13.9%).
👉 More details: https://platform.spotonchain.ai/en/entity/1756
✅ Set alerts for $MKR with us now to avoid missing an opportunity: https://platform.spotonchain.ai/en/platform/token?name=MKR
RoOLZ Gods & Mortals: Exciting Updates Ahead
#SocialFi#MEXC
RoOLZ Gods & Mortals celebrates the distribution of SocialFi rewards from the last event, while addressing a listing issue on MEXC. Get ready for the upcoming May SocialFi event, focusing on viral videos and engagement, with details to come soon. Don't miss today's Comput3ai livestream at 12 pm ET.
Source: link
@tonlines
🚨#MEXC New Listing Alert!
📈 $HOLD/USDT will be listed in the Innovation Zone on 2024-12-16 13:00 (UTC).
In the crypto asset management simulator game #HoldCoin, which is based on Telegram, users can HOLD assets and create a portfolio to generate coins.
Details: https://www.mexc.com/support/articles/17827791520405