Отдельно разберём 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
⚔️ The Sabre Grand Prix is underway in Orléans!
Strong Asian presence from:
🇯🇵 Japan, 🇰🇷 Korea, 🇭🇰 Hong Kong, 🇨🇳 China, 🇺🇿 Uzbekistan, 🇰🇿 Kazakhstan, 🇯🇴 Jordan, 🇮🇷 Iran, 🇰🇼 Kuwait, 🇲🇾 Malaysia, 🇸🇦 Saudi Arabia, 🇸🇬 Singapore, 🇹🇼 Chinese Taipei.
🔥 14 Asian athletes advance to the December 6 main draw.
Good luck to all!
📸 Photos by Eva — FIE Team
#FIE#FCA#AsianFencing
All delegations have arrived… and the real preparation begins ⚔️🔥
Athletes have started their official training sessions at the competition venue, ahead of tomorrow’s Asian Cadet & Junior Fencing Championships, featuring a large participation of Asia’s rising talents 🌏
Sharp focus, strong determination, and exciting energy ahead of the first bout 🏆
Tomorrow… it begins.
🌐www.asian-fencing.com
Follow @fencing_fca
#AsianFencing#FCA#CadetJunior#RoadToGlory
⏳ Just 1 month to go!
Asia’s future fencing stars will meet in
Jakarta, Indonesia 🇮🇩
for the Asian Cadet & Junior Fencing Championships 2026 🤺
📅 20–27 February 2026
📍 Jakarta
The countdown is on.
Are you ready? 🔥
🌐www.asian-fencing.com
Follow @fencing_fca
#AsianFencing
#FCA
#AsianCadetJunior
#Fencing2026
#Jakarta2026
🥇🏆 The Moment of Glory!
A proud scene from the podium at the Asian Cadet Fencing Championships – Kuala Lumpur 2025 🇲🇾⚔️
From Hong Kong to Kazakhstan and Uzbekistan, fencers shined with skill, passion, and true sportsmanship 💪
Congratulations to the Men’s Foil medalists on an outstanding performance and well-deserved victories! 👏
🥇 HO Shing Him Harris 🇭🇰
🥈 LAM Ho Long 🇭🇰
🥉 NURUMOV Galim 🇰🇿
🥉 MOLINA Ilyas 🇺🇿
#Fencing#AsianFencing#MensFoil#KualaLumpur#FencingAsia#Championships#FencingSpirit
🏆 Asian Senior Fencing Championship – Bali 2025 🗡️
This is where legends are forged ✨
Where pleasure 🎉, dignity 🛡️, and the spirit of competition 🔥 collide!
The thrill of victory 🥇, the clash of steel ⚔️, and the soul of competition 🏃♂️
All in one place — glory carved in blades, legends born in every touch ⚡
#Bali welcomes the elite 🤺
#AsianFencingChampionship 2025 🌏
#FCA#FencingAsia#Bali2025
#FencingPower#BladesOfGlory#Honor#AsianFencing
🔟 Only 10 Days to Go!
The countdown has begun for Asia’s ultimate fencing spectacle ⚔️🌏
Get ready as the 2025 Asian Senior Fencing Championships land on the breathtaking island of Bali! 🌺🌴
📍 Bali, Indonesia 🇮🇩
📅 June 17–23, 2025
⏳ Seven days. One stage. Endless glory.
✨ Witness:
⚡ Elite fencers from across Asia battle for supremacy
🔥 Unforgettable showdowns & rivalries reborn
🥇 New legends rising — champions forged in every bout
🎯 Precision. Passion. Power. Every point is everything.
📡 Stay tuned for:
🔴 Live updates
🎞️ Daily highlights
🎥 Behind-the-scenes action
📸 Exclusive content you won’t want to miss!
🚀 The road to greatness starts now — and it leads through Bali.
Don’t just watch history… be part of it.
🔽 Follow us & gear up for the fight of the year!
#AsianFencing#Bali2025#UnleashTheBlade
#CountdownToGlory#FencingAsia#SeniorFencing
#ChampionsRise#BladesOfAsia#FIE#TopFencers
#Indonesia#FencingElite#RoadToVictory#AFC