Функция asyncio.wait() это еще один способ вызвать множество асинхронных задач.
Она работает в нескольких режимах.
1. Самый простой - ждем завершения всех задач
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(10)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.ALL_COMPLETED
)
for task in done:
try:
print(task.result())
except Exception as e:
print(e)
Очень похоже на gather, но работает не так.
▫️возвращает не результаты, а два сета с объектами Task у которых можно забрать результат через task.result() если они в списке done
▫️не гарантирует порядок результатов так как оба объекта это set
▫️не выбрасывает исключение когда оно появляется, а сохраняет его в Task. Исключение появится когда попробуете забрать резултьтат.
2. Ждем завершения первой задачи, даже если там ошибка.
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(3)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_COMPLETED
)
# в done может быть несколько задач!
for task in done:
try:
print(task.result())
except Exception as e:
print(f"Fail: {e}")
# Оставшиеся задачи в pending, как правило, нужно отменить, иначе они будут продолжать работать
for task in pending:
task.cancel()
В сете done будут таски которые успели завершится, причем как успешно так и нет.
3. До первой ошибки.
Тоже самое, но с аргументом FIRST_EXCEPTION
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_EXCEPTION
)
Функция завершается как только первая задача упадет с ошибкой.
Учтите, что в любом случае done вы можете обранужить несколько задач, как с ошибками так и успешные.
↗️ Полный листинг примеров здесь
#async
Ethiopia’s Ruling Party Central Committee Meeting Ahead of National Election. Read more.
https://borkena.com/2026/02/19/ethiopias-ruling-party-central-committee-meeting-ahead-of-national-election/#Ethiopia#EthiopiaNews#Prosperityparty
Andargachew Tsege says EZEMA dead as a political party for a long time. Read more.
https://borkena.com/2026/03/10/ethiopia-andargachew-tsege-says-ezema-dead-as-a-political-party-for-a-long-time/#AndargachewTsege#EthiopiaNews#EZEMA
Berhanu Nega’s Criticism Of The Opposition Quarter, Reactions To It.
https://borkena.com/2026/03/10/ethiopia-berhanu-negas-criticism-of-the-opposition-quarter-reactions-to-it/#EthiopiaNews#News#EZEMA#BerhanuNega#News
Weekly Recap | Addis Standard
Top stories of the week from Ethiopia and the region.
Watch the full recap.
https://youtu.be/Sm_a10BhwSA?si=1FfftVvZP-wBI7Ny
#Ethiopia#AddisStandard#EthiopiaNews#HornOfAfrica#WeeklyNews
Weekly Recap | Addis Standard
Top stories of the week from Ethiopia and the region. Watch the full recap.
#Ethiopia#AddisStandard#EthiopiaNews#HornOfAfrica#WeeklyNews
https://www.youtube.com/watch?v=OlJTzSXAltc
From regional diplomacy to public health updates—here’s what shaped the week in East Africa.
👉 Addis Standard Weekly News Recap covers:
• Red Sea security talks involving Eritrea and Sudan
• Ethiopia’s latest Marburg update
• Major changes in Ethiopia’s media leadership
• U.S.–Somalia aid suspension
• Visa denials affecting Ethiopian athletes
• And more regional & global developments
▶️ Watch, share, and stay informed with Addis Standard.
https://www.youtube.com/watch?v=7n-nq-Dg1Ow
#WeeklyRecap#EthiopiaNews#HornOfAfrica#AddisStandard#AfricanNews
#Premiering_now: The Standard Signal | Ep.15: Ethiopia Under Pressure: Fuel Crisis, Global & Regional Instability, a Fragile Election | Jawar Mohammed
Click here to watch: https://www.youtube.com/watch?v=HexAbPk8Dkw
Ethiopia is facing mounting pressures. In Episode 15 of The Standard Signal, host Tsedale Lamma brings Jawar Mohammed to discuss the deepening fuel shortage and corruption concerns in Ethiopia, the looming fertilizer crisis and its implications for food security, and the impact of Middle East war on Ethiopia’s economy and stability.
#AddisStandard#TheStandardSignal#Ethiopia#JawarMohammed#EthiopiaPolitics#Corruption#FuelCrisis#HornOfAfrica#Tigray#Amhara#Oromia#EthiopiaElection#AfricaPolitics#EthiopiaNews#AfricanPolitics#Geopolitics
#Coming_UP: The Standard Signal | Ep.15: Ethiopia Under Pressure: Fuel Crisis, Global & Regional Instability, a Fragile Election | Jawar Mohammed
#TsedaleLemma speaks with #JawarMohammed about the growing challenges facing Ethiopia, from global and regional tensions to domestic instability, corruption and Ethiopia’s fragile election.
Premiers at: 7:30 PM EAT tonight.
Subscribe to watch: https://www.youtube.com/@AddisStandard
#AddisStandard#TheStandardSignal#Ethiopia#JawarMohammed#EthiopiaPolitics#Corruption#FuelCrisis#HornOfAfrica#Tigray#Amhara#Oromia#EthiopiaElection#AfricaPolitics#EthiopiaNews#AfricanPolitics#Geopolitics