Отдельно разберём TaskGroup, который пришел на замену gather в Python 3.11.
Ключевые отличия
▫️create_task() возвращает объект asyncio.Task, у которого есть соответствюущие методы управления. То есть у нас больше контроля
▫️это контекстный менеджер, который гарантирует что все таски будут остановлены по выходу из контекста
▫️ошибка автоматически отменяет незавершенные задачи,
▫️except* передает нам ExceptionGroup, в котором каждую ошибку можно обработать отдельно
import asyncio
import random
async def do_it() -> str:
if random.random() < 0.1:
raise ValueError('Oops')
delay = random.uniform(0.5, 1.5)
await asyncio.sleep(delay)
return delay
async def main():
try:
async with asyncio.TaskGroup() as tg:
for _ in range(10):
tasks.append(tg.create_task(do_it()))
for t in tasks:
print(t.result())
except *ValueError as e:
for err in e.exceptions:
print(err)
asyncio.run(main())
Рекомендую изучить страницу Coroutines and Tasks из документации, где представлено больше интересных примеров и механизмов
- таймауты
- отмена задач
- создание задач из другого потока
#async
🔥 What's up with the listing of HOT and the project overall ?
⚡️ Futures on HOT can already be traded on the 🐂#WhiteBIT exchange, and the price is promising 🤘
Chart on the screenshot, 1 HOT = 19.803 USDT). When spot trading for HOT will be launched is just a matter of time...
.
🙂#MineHOT here:
https:://t.me/herewalletbot/app👈
🔥
🔥 What's up with the listing of HOT and the project overall ?
⚡️ Futures on HOT can already be traded on the 🐂#WhiteBIT exchange, and the price is promising 🤘
Chart on the screenshot, 1 HOT = 9.142 USDT). When spot trading for HOT will be launched is just a matter of time...
.
🙂#MineHOT here:
https:://t.me/herewalletbot/app👈
🔥
🔥 What's up with the listing of HOT and the project overall ?
⚡️ Futures on #HOT can already be traded on the 🐂#WhiteBIT exchange, and the price is promising 🤘
Chart on the screenshot, 1 HOT = 6.600#USDT). When spot trading for HOT will be launched is just a matter of time...
.
🙂#MineHOT here:
https:://t.me/herewalletbot/app👈
➖
🔥 What's up with the listing of HOT and the project overall ?
⚡️ Futures on #HOT can already be traded on the 🐂#WhiteBIT exchange, and the price is promising 🤘
Chart on the screenshot, 1 HOT = 8.438#USDT). When spot trading for HOT will be launched is just a matter of time...
.
🙂#MineHOT here:
https:://t.me/herewalletbot/app👈
➖
#Light#of#Mine#Bible#Audio
Join the Light of Mine: Bible + Audio beta on ✈️#TestFlight
🔗 Link: https://testflight.apple.com/join/Y1Z7Y4Ss
Shared by Dimitri
🔥 What's up with the listing of HOT and the project overall ?
After #Notcoin🤑, one of the major applications that launched was:
HOT Near #Wallet. "How to mine - HERE
⚡️ The developers are actively engaging in marketing and have already formed numerous collaborations. In the past two days, they partnered with #1inch and added MPC wallets.
⚡️ Direct support from #Near: it's already evident that all transactions are being recorded on the blockchain. We are #mining a real token, not just pixels on a screen! Moreover, HOT plans to launch its own blockchain.
⚡️ Futures on #HOT can already be traded on the 🐂#WhiteBIT exchange, and the price is promising 🤘 (chart on the screenshot, 1 HOT = 3.987 #USDT). When spot trading for HOT will be launched is just a matter of time...
💯 In conclusion, we can say that the game has a strong foundation and prospects for future development.
🙂#MineHOT here:👇👇
https://t.me/herewalletbot/app?startapp=200850-village-15134