Отдельно разберём 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
#MATIC/USDT analysis -
#Matic is trading above the support zone and forming a rejection candle. It is expected to bounce off from there and test new highs.
TF : 1D
Entry : $0.5148
Target : $0.5740 & $0.6198
SL : $0.4579
#MATIC/USDT ANALYSIS
MATIC has broken out of a falling wedge pattern with strong volume. It is currently undergoing a retest, and a successful retest would confirm a bullish reversal. However, if the retest fails, the pattern's validity will be nullified.
💰#MATIC is losing bottom of the bullish channel on 1H Time frame,in the case of breakdown,it will drop until the Green zone
📉
❄️@signal_bitcoins❄️
❄️@Shadow_support0o❄️
💰#MATIC has a Bullish flag pattern on Weekly time frame,now price is trying to break up the flag pattern👀
We expect another bullish trend will start after breakout and pullback💎
❄️@signal_bitcoins❄️
❄️@Shadow_support0o❄️
💰#MATIC created a symmetrical triangle pattern successfully on Weekly time frame,we expect a huge drop on this chart
📉
Also we will buy it around $0.30 - $0.20✅
❄️@signals_bitcoin_crypto❄️
❄️@Shadow_support0o❄️
💰#MATIC price is near the bottom of bullish channel on 8H Time frame,if saved this area will have good pump again, atleast until ceiling of this pattern 💎
❄️@signals_bitcoin_crypto❄️
❄️@Shadow_support0o❄️
💰#MATIC is trying to break up the Supply zone,we will wait for a pullback to the broken supply then will buy and hold✅
❄️@signals_bitcoin_crypto❄️
❄️@Shadow_support0o❄️