Отдельно разберём 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
🚀 Gas-Free Transfers are now live on Solana!
With TokenPocket, enjoy:
✨ 3 free transfers every day
✨ Fast, reliable on-chain transactions
Make every move cost-effective with #GasFreeWallet💙
→ https://help.tokenpocket.pro/en/wallet-faq-en/solana-wallet/gas-free-service-on-solana
⛽️Gas Fee? Gas Free!
No more worrying about running out of $TRX for gas fees — TokenPocket now supports $USDD for gas payments, with a limited-time subsidy!
Enjoy a smoother, faster, and more efficient experience on the TRON network. #StablecoinWallet#GasFreeWallet
🎥 Watch how it works: https://youtube.com/watch?v=gndDfJBN_cg
🔋Gas-Free Stablecoin Transfers? TokenPocket makes it real.
→ https://help.tokenpocket.pro/en/wallet-operation/stablecoin/gas-free
✅Zero fees, lightning-fast transactions on BNBCHAIN & TRON
✅Trusted by 30M+ users worldwide - fast, affordable, secure.
Experience the future of stablecoin wallets with TokenPocket. #StablecoinWallet#GasFreeWallet
📝 TokenPocket Monthly Report — December 2025
→ https://tokenpocket-gm.medium.com/tokenpocket-monthly-report-december-2025-c0cd0518efa7
In December, TokenPocket launched a series of measures under the theme of technological innovation and community activities, covering multiple dimensions such as multi-chain function upgrades, trading experience, ecosystem cooperation expansion, security protection enhancements, and transfer experience optimization.
🎯#SAFU
TokenPocket's anti-phishing function is comprehensive. Combined with security functions like Privacy Wallet and Passphrase, it jointly safeguards the security of your assets.
🎯#StablecoinWallet & #GasFreeWallet
TokenPocket now supports Multi-Chain Gas Payment with Stablecoins on base, arbitrum, and BNBCHAIN. Combined with 0 gas fee transfers services on trondao, solana, and BNB Chain, this further solidifies TokenPocket as your go-to choice for a Stablecoin Wallet.
📍 All In One, All in TokenPocket
https://t.co/OVU2yXAPqA
🟥The Gas-Free Transfer on TRON on TokenPocket is live! 🍌
😍Get your TRON Gas Coupons NOW!
✅Comment [Gas-Free On TokenPocket] below👇
💰For 100 winners!
💎With TokenPocket’s TRON Gas Coupons, you can save up to 100% on gas costs on the TRON Network, allowing you to enjoy truly GAS-FREE transfers and trading experiences on TRON!
Details👉https://help.tokenpocket.pro/en/wallet-faq-en/tron-wallet/coupon
#TRON#TokenPocket#GasFree#ZeroGas#GasFreeWallet