Функция 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
The EPRP Rises Again: A Fearless Spirit Confronts Abiy’s Fearful Regime. Read more.
https://borkena.com/2025/12/07/ethiopia-eprp-rises-again-a-fearless-spirit-confronts-abiys-fearful-regime/#Ethiopia#politics#EPRP
EPRP Central Committee Meeting, Vows To Intensify Its Struggle For Ethiopians. Read more.
https://borkena.com/2025/11/19/eprp-central-committee-meeting-vows-to-intensify-its-struggle-for-ethiopians/#Ethiopia#Politics#EPRP
EPRP Calls For A Public Meeting In Addis Ababa. Read more.
https://borkena.com/2025/11/22/ethiopia-eprp-calls-for-a-public-meeting-in-addis-ababa/#Ethiopia#News#EPRP#PublicMeeting
News: #EPRP says politician #Yeshiwas Assefa arrested, calls for immediate release
The #Ethiopian People’s Revolutionary Party (EPRP) has announced that politician Yeshiwas Assefa has been arrested, saying it confirmed the development through his family members.
In a statement issued today, the party said Yeshiwas was taken into custody yesterday, describing the arrest as part of what it called the government’s continued crackdown on citizens engaged in peaceful political activity.
“This is one of the countless acts that demonstrate the government’s ongoing suppression of citizens engaging in peaceful political activities,” the statement read.
The EPRP further argued that such actions cast doubt on the credibility of the upcoming elections, which ruling party officials have repeatedly pledged will be free, fair and democratic. Instead, the party said, the current
https://web.facebook.com/AddisstandardEng/posts/pfbid0haYBwZFd8QeABk6i1v9kN4LtHyVXkPGG4mFcjx4T6UPUAx1SVkJ5PCi2FpXQ74Col
EPRP Press Conference on planned demonstration. Watch it.
https://borkena.com/2026/04/15/eprp-press-conference-on-planned-demonstration/#Ethiopia#News#EPRP#EthiopianNews#politics#EthiopianPolitics
EPRP Holding Its Public Meeting This Saturday In Addis Ababa. Read. https://borkena.com/2025/12/03/eprp-holding-its-public-meeting-this-saturday-in-addis-ababa/#Ethiopia#EPRP#AddisAbaba#opposition
News: #EPRP signals readiness to bypass electoral board for nationwide protests
Ethiopian People’s Revolutionary Party says it will proceed with planned demonstrations in ten cities on 8 May, 2026, even if it does not receive approval from the National Election Board of Ethiopia, citing constitutional guarantees on the right to assembly.
Speaking to Addis Standard, #Mistireslassie_Tamrat, EPRP’s General Secretary, said the party had formally notified #NEBE ahead of the planned protests but has yet to receive any response.
“Regarding the letter we submitted to the Electoral Board, we have not received any response so far; they haven’t notified us of anything, and we are still waiting,” she said.
Despite the lack of communication, Mistireslassie indicated that the party is prepared to move forward outside the electoral framework if necessary. “If this demonstration cannot proceed through the Electoral Board's framework, we will
Read more: https://addisstandard.com/?p=56537