Отдельно разберём 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
crDroid - Unofficial | Android 16 | Nothing Phone (2)
📝 Details:
- Version: v12.3
- Device: #Pong
- Released: 15/11/25
⬇️ Downloads: ROM and Recovery Image
⚙️ Flashing Instructions: Here
📖 Changelogs: Here
🏷 Tags: #LOS#ROM#crDroid#Unofficial
✍️Notes:
- GAPPS and Vanilla builds available
- Dolby and initial Nothing camera support available
- WFD broken
- SukiSU Ultra with SUSFS out of the box
- OTA updates are supported
- Signed with release-keys
- Use latest NOS 3 firmware
- If face any bugs report with logs
🏆Credits:
- Ghost and Chandu for DT
- Fabian & HELLBOY for Glyph
- HELLBOY for Meteoric Kernel
👤 Maintainer: @deadlylxrd
💬 Chat: @NothingPhone2
🔔 Updates: @NothingPhone2Updates
OrionOS Project - OFFICIAL | A14 | Nothing Phone (2)
Based on LineageOS & crDroidAndroid
📔 Details:
- Version: Cosmic
- Codename: #Pong
- Released: 04/08/2024
🔽 Download (Recovery) : Vanilla | Gapps
⚙️ Installation: Here
📸 Screenshots: Here
🆘 Support: Telegram
🔖 Tags : #ROM#LOS#Official#QPR3#U#NothingPhone2
✍️ Note:
- Kernel is prepatched with KSU (Download Manager)
- Clean flashing is mandatory
- Both Vanilla & Gapps Build Available
- Powershare (Wireless Reverse Charging)
- Auto brightness in Glyph
- X-Reality Engine in Colors
- MicroG should pass Integrity (Not tested)
- Game Space
- Battery Backup was pretty decent during testing.. Wait for a charging cycle to complete..
‼️ Known Bugs:
- Lock Screen Carrier Text is a bit right.. Would be fixed with next OTA of August SP
🏆 Credits
- Chandu for base device tree & Kernel
- OC'D, Miki, Unluck & Ghost for all help
- Fabian & Hellboy for PA Glyph
- Testers
😎 Maintainers: @AgBKartikey
🔔 Updates: @NothingPhone2Updates
💬 Chat: @NothingPhone2