Отдельно разберём 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
#ARDR/USDT analysis :
#ARDR is in a bearish trend, consistently making lower lows (LLs) and lower highs (LHs) below the 200 EMA. The price is currently rejecting from the 200 EMA and is anticipated to resume its downward movement, targeting lower levels.
TF : 4H
Entry : $0.07035
Target : $0.05818
SL : $0.07815
#ARDR👈
https://www.binance.com/en/trade/ARDR_BTC
Buying Zone 540-550👈
Buy in parts n successive dips
Strictly follow as directed
On the verge of hardcore pump
Sell
🤑 620-650
🤑 650-700
🚀 700-800
💃 800-900 & above
#ARDR/USDT analysis :
After breaking out above the 200 EMA, the #Ardor has retested it and consolidated sideways over the support zone. Recently, the price has bounced back from the support zone, and it is anticipated to continue its bullish momentum to test the previous swing high level.
TF : 1D
Entry : $0.09132
Target : $0.12550
SL : $0.07356
Roaring Kitty Hints at Comeback
🐦 Roaring Kitty, a key figure in the GameStop stock surge, teases a return. His recent tweet features a video, sparking nostalgia and speculation about upcoming moves. Kitty symbolizes retail investor resistance against Wall Street, igniting the meme stock revolution in 2021.
🔗Roaring Kitty's tweet
🔗 Whale Alert: $102M in #BTC transferred Details here
🔗 Bithumb launches new ARDR & QKC trading Read more
#GameStop#RoaringKitty#memeStocks#BTC#Crypto#VC#RetailInvestors#WhaleAlert#SouthKorea#Trading#Bithumb#ARDR#QKC#Investing#MarketNews#Finance#Nostalgia#Tease#Speculation