Отдельно разберём 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
¡Ya es oficial! ✅
🔴 El #PlanB de reforma electoral contempla la reducción de salarios a funcionarios electorales 🇲🇽👏🏻👀
https://revistaelpolitico.com/nacional/publican-plan-b-reforma-electoral-dof/
Trader #PlanB expressed an interesting idea about how future large ETFs provide themselves with Bitcoins:
"ETFs, in my opinion, such as #BlackRock, are currently loading $BTC through miners, not through exchanges. Buying #BTC directly on exchanges will affect the price too much. An indirect purchase from miners will affect the hashrate, but not the price. This can explain the current hashrate explosion"
¡No más privilegios! ❌💰
🔴#Sheinbaum celebró que el #PlanB ya es constitucional enlistando los 6 logros de esta ley que sigue haciendo llorar a la oposición 🗳️👏🏻
Tsss… 😱
🔴 Luego de la postura en contra del #PlanB de Sheinbaum, los mexicanos disminuyeron su confianza en el #PT🔥‼️👇🏻
https://sinlineamx.com/voto-de-pt-contra-plan-b-representa-ruptura-con-morena/
¡Necios, pero necios! 🙄
🔴 A pesar de que muchos mostraron descontento por la decisión, el #PT sigue insistiendo en no hacer cambios a la iniciativa del #PlanB enviada desde el Senado 🤬🇲🇽🗳️
https://revistaelpolitico.com/nacional/pt-aprobara-plan-b-si
Lo bueno es que no querían perder votos 😅
🔴 ¿Cómo crees que le vaya al #PT en 2027 tras la polémica con el #PlanB? 🤔👇🏻
https://sinlineamx.com/tunden-pt-por-eliminar-revocacion-mandato-plan-b/
¿Se consumó una nueva traición? 🤔
🔴 El #PT jugó del lado del McPRIAN y tumbó la revocación de mandato con una reserva al #PlanB🙄 | Así se vivió la sesión 👇🏻
https://sinlineamx.com/revocacion-de-mandato-queda-fuera-plan-b-pt/
¡Y siguen! 🙄
🔴 Ahora resulta que el #PT solo posó para la foto y dio un falso respaldo al #PlanB de #Sheinbaum😡📄🔍
https://sinlineamx.com/pt-niega-acuerdo-definitivo-morena-sobre-plan-b/
Аналитик PlanB ожидает, что после халвинга курс биткоина достигнет $100 000 в 2024 году, а на пике в 2025 году — $300 000.
Он считает, что текущий цикл ничем не отличается от предыдущих и заявил, что лучшая стратегия — покупка биткоина за 6 месяцев до халвинга и продажа через 18 месяцев.
При таких прогнозах курс Крипто Индекса WBT может достигнуть цены в 5 usdt.
Сегодня самое время докупиться.
#халвинг#мнение#PlanB
PlanB Shifts Funds to Crypto ETFs
Crypto analyst PlanB has transitioned his capital from Bitcoin savings to spot ETFs based on digital gold, deeming it a rational progression towards Bitcoin adoption. His move sparked mixed reactions within the community, with some viewing it as a mistake. Meanwhile, BNB Chain's team is optimizing transaction processing for meme coins following updates aimed at increasing the validator's capacity to process transactions efficiently. Recent judicial developments involving Binance and the SEC may also be influencing market dynamics.
#Crypto#Bitcoin#ETF#BNBChain#SEC#MemeCoins#PlanB