Три способа выполнить множество задач с asyncio
Функция для примера:
async def do_it(n):
await asyncio.sleep(random.uniform(0.5, 1))
return n
1. Последовательный вызов
async def main():
for i in range(100):
result = await do_it(i)
Такой вызов имеет смысл только тогда, когда результат одной задачи требуется для вызова следующей.
Если они независимы, то это антипаттерн, так как аналогичен простому синхронному вызову по очереди.
2. Упорядоченный результат
async def main():
tasks = [do_it(i) for i in range(100)]
results = await asyncio.gather(*tasks)
Выполняет корутины конкурентно и возвращает результат в виде списка.
Полезен когда требуется получить результаты в том же порядке в котором задачи отправлены.
3. Результат по мере готовности
tasks = [asyncio.create_task(do_it(i)) for i in range(100)]
for cor in asyncio.as_completed(tasks):
result = await cor
Так же выполняет корутины конкурентно, но не гарантирует порядок. Результат возвращается по мере готовности, каждый отдельно.
Полезен когда нужно обработать любой ответ как можно скорее.
#async
Nameless AOSP - Official | Android 13 | Nothing Phone (2)
📝 Details:
- Version: 1.4
- Status: #Official
- Device: Pong
- Released: 26/11/23
⬇️Download : Build l Images
👀 Changelogs : Here
🌳Device Tree : Here
📔Flashing Instructions : Here
🎙Support Group: Here
🏛 XDA : Here
📸 Screenshots:Here
💰Donate : Paypal | UPI : chandudyavanapelli3-1@okhdfcbank
🏷Tags : #AOSP#ROM#Nameless#T
❌Known Issues:
- No NFC Support (Sadly PN560 NFC is not supported in Android 13. Will be revisited once we move to Android 14)
✍️Note:
- Report issues (if any except known ones) with logs in support group / comments
- This is the final Android 13 release. We will start work on Android 14 from 2024 January.
🏆 Credits:
- Chandu Dyavanapelli for initial DT bringup
- Pong Dev and Testing Team & Contributors
👤 Maintainer : @Chandu_Dyavanapelli
🔔 Updates : @NothingPhone2Updates
🐙 Chat : @NothingPhone2
Nameless AOSP | Android 13 | Nothing Phone (2)
📝 Details:
- Version: 1.4
- Build: #Beta
- Status: #Official
- Device: Pong
- Released: 12/11/23]
⬇️Download : Build l Images
🌳Device Tree : Here
📔Flashing Instructions : Here
🎙Support Group: Here
📸 Screenshots:Here
💰Donate : Paypal
🏷Tags : #AOSP#ROM#Nameless#T
✨ Changelogs:
- Initial Test Build
❌ Known issues:
- NFC is broken, causing the system UI to crash after every reboot, but only once.
- Haptics are not similar to stock but will improve in upcoming builds.
- Dont use "Hey Google" as it leads to crashdump. Use factory reset to revive.
- Some device specific features are not added, will be added eventually.
- Report bugs (with logs ofc) in the comment section.
🏆 Credits:
- Chandu Dyavanapelli for initial DT bringup
- Pong Dev and Testing Team & Contributors
👤 Maintainer : @Chandu_Dyavanapelli
🔔 Updates : @NothingPhone2Updates
🐙 Chat : @NothingPhone2
Nameless CLO - Official | Android 15 | Nothing Phone (2)
🗒 Details:
- Version: A15
- Codename: #Pong
- Released: 22/12/24
🔽 Download: ROM [ Sourceforge l Mirror ] || Images [ Sourceforge l Mirror ]
🆘 Support : Telegram l Wiki
⚙️ Installation: Here
📸 Screenshots: Here
💵 Donate: Paypal | UPI: dyavanapellichandu@ybl
🔖 Tags : #ROM#CLO#Nameless#V#Official#NothingPhone2
✨Source Changelogs:
- Initial A15 Release based on CLO
✍️ Note:
- A clean flash is required if you're coming from Nameless-AOSP or any custom ROMs.
- You will not receive OTA updates in Nameless-AOSP for this build.
👤 Dev : Chandu Dyavanapell
🔔 Updates : @NothingPhone2Updates
💬 Chat : @NothingPhone2
Nameless AOSP - Official | Android 14 | Nothing Phone (2)
🗒 Details:
- Version: A14 - Final
- Codename: #Pong
- Released: 14/09/24
🔽 Download: Here | Mirror
🆘 Support : Here
⚙️ Installation: Here
📸 Screenshots: Here
💵 Donate: Paypal | UPI: dyavanapellichandu@ybl
🔖 Tags : #ROM#AOSP#Nameless#QPR3#U#Official#NothingPhone2
✨Source Changelogs:
- Merged September security patch
- Updated default wallpaper and boot animation
- Add navbar animation in pixel launcher
- Stability improvements and minor fixes
✍️ Note:
- This is the final A14 release and no OTA update exists for the same.
- Please update manually in recovery mode
👤 Dev : Chandu Dyavanapell
🔔 Updates : @NothingPhone2Updates
💬 Chat : @NothingPhone2