Функция 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
arter97 Kernel | Android 14 | Nothing Phone (2)
✍️ Details:
- Version: r15
- Codename: #Pong
- Released: 15/03/24
🔽 Download: Normal & KSU Version
🆘 Support Threads: TG | XDA
🔖Tags : #Stock#Kernel#arter97#U
✨Changelogs:
- Backported lazy RCU to improve power consumption
- Other minor bug fixes and changes from Google
✍️ Note:
- This kernel is only compatible with Stock A14 NOS rom.
- Report issues (if any) in the support group with appropriate logs.
😎 Maintainer : @arter97
🔔 Updates : @NothingPhone2Updates
💬 Chat : @NothingPhone2
NothingMuchROM | Android 14 | Nothing Phone (2)
Nothing OS with some handful modifications for a better experience
✍️ Details:
- Version: r15 (NOS 2.6.0)
- Codename: #Pong
- Released: 08/07/24
🔽 Download : Here
🆘 Support group: TG | XDA
⚙️ Installation: Here
🔖Tags : #Stock#ROM#arter97#U#NothingPhone2
✨Changelogs:
- Stable release based on 2.6.0
- Custom bionic updated to use the latest AOSP compiler and fix several minor issues in the math library.
😎 Developer: @arter97
🔔 Updates: @NothingPhone2Updates
💬 Chat: @NothingPhone2
NothingMuchROM | Android 14 | Nothing Phone (2)
Nothing OS with some handful modifications for a better experience
✍️ Details:
- Version: r14 (NOS 2.5.6)
- Codename: #Pong
- Released: 02/07/24
🔽 Download : Here
🆘 Support group: TG | XDA
⚙️ Installation: Here
🔖Tags : #Stock#ROM#arter97#U#NothingPhone2
✨Changelogs:
- Stable release based on NOS 2.5.6
- Dirac is back, thanks to the fix from gotenksIN
✍️ Note:
- If you don't want dirac, stick to the r13 build based on NOS 2.5.6
😎 Developer: @arter97
🔔 Updates: @NothingPhone2Updates
💬 Chat: @NothingPhone2
NothingMuchROM | Android 16 | Nothing Phone (2)
✍️ Details:
- Version: r40
- Codename: #Pong
- Released: 10/03/26
🔽 Download : Here
🆘 Support group: Here
⚙️ Installation: Here
🌳 Source: Here
🔖Tags : #Stock#ROM#arter97#V#NothingPhone2
✨ Changelogs
- Update base to 4.0 (Pong_B4.0-260226-0955)
🗒 Note:
- Back up your data before proceeding.
- Make absolutely sure that you're flashing the respective firmware alongside the installation. Failure to do so will result in an untested scenario.
- Recovery flashable firmwares can be found here.
- It is recommended to use arter97's latest kernel build with this ROM.
👤 Developer: @arter97
🔔 Updates: @NothingPhone2Updates
💬 Chat: @NothingPhone2
NothingMuchROM | Android 15 | Nothing Phone (2)
✍️ Details:
- Version: r39
- Codename: #Pong
- Released: 20/09/25
🔽 Download : Here
🆘 Support group: Here
⚙️ Installation: Here
🔖Tags : #Stock#ROM#arter97#V#NothingPhone2
✨ Changelogs
- Update base to Pong-V3.2-250917-1451
🗒 Note:
- Back up your data before proceeding.
- Make absolutely sure that you're flashing the respective firmware alongside the installation. Failure to do so will result in an untested scenario.
- Recovery flashable firmwares can be found here.
- It is recommended to use arter97's latest kernel build with this ROM.
👤 Developer: @arter97
🔔 Updates: @NothingPhone2Updates
💬 Chat: @NothingPhone2
NothingMuchROM | Android 15 | Nothing Phone (2)
✍️ Details:
- Version: r37
- Codename: #Pong
- Released:15/07/25
🔽 Download : Here
🆘 Support group: Here
⚙️ Installation: Here
✨ Changelogs: Here
🔖Tags : #Stock#ROM#arter97#V#NothingPhone2
🗒 Note:
- Back up your data before proceeding.
- Make absolutely sure that you're flashing the respective firmware alongside the installation. Failure to do so will result in an untested scenario.
- Recovery flashable firmwares can be found here.
- Stable release based on 3.2 (Pong_V3.2-250708-2227_3.2)
- It is recommended to use arter97's latest kernel with this ROM.
👤 Developer: @arter97
🔔 Updates: @NothingPhone2Updates
💬 Chat: @NothingPhone2
NothingMuchROM | Android 15 | Nothing Phone (2)
✍️ Details:
- Version: r36
- Codename: #Pong
- Released: 23/05/25
🔽 Download : Here
🆘 Support group: Here
⚙️ Installation: Here
✨ Changelogs: Here
🔖Tags : #Stock#ROM#arter97#V#NothingPhone2
🗒 Note:
- Back up your data before proceeding.
- Make absolutely sure that you're flashing the respective firmware alongside the installation. Failure to do so will result in an untested scenario.
- Recovery flahsable firmwares can be found here.
- Flashing super is enough for users coming from r35.
- Stable release based on NOS 3.0, Build: Pong-V3.0-250506-1805.
- It is recommended to use arter97's latest kernel with this ROM.
👤 Developer: @arter97
🔔 Updates: @NothingPhone2Updates
💬 Chat: @NothingPhone2