Отдельно разберём 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
UndeadWallpaper
UndeadWallpaper is a free, balls-to-the-wall Android app that brings your screen to life... or, well, un-death by letting you slap any of your favorite videos on it as a seamless, stutter-free live wallpaper.
🔗 Links:
- Download
- Screenshots
- Features
- Source code
Developer: まおう
🫂 Special thanks to ᴅᴜxᴛᴀᴍɪ for recommending!
❤️ Support the Project
If this project makes your life easier, here are a few quick ways to show some love:
⭐ Star the repo/app
☕ Buy a coffee for the developer
🛠 Contribute code, issues, or pull-requests
🏷 Tags: #Android#Customization
Hey everyone, happy Sunday! 🌞 Here's the #wallpaper many of you requested after my last reel. I've also made some tweaks to give more space for your home screen widgets. Hope you enjoy it! 📱✨#homescreen#customization"
Fossify Launcher
Fast, personalized, and privacy-first home screen experience. No ads, no bloat – just a smooth, efficient launcher designed to fit your unique style and preferences.
🔗 Links:
- Download from: Github or IzzySoft
- Screenshots
- Features
- Source Code
🌐@popmodsnetwork
🎁Donate to our admins
🏷 Tags: #Android#Customization#Fossify#Launcher
Channel: Icon Pacls and Wallpapers for Android and iOS
Members: ~3.2K
💢 Username: @pizzapp_design
Description:
Icon Packs & Wallpapers Customize with ️ and Social Links https://linktr.ee/pizzappdesign Customizers Community Group https://t.me/customizerscommunity
🏷 Tags: #art_design
#iconpack#wallpapers#android#ios#customization
https://telegramchannels.me/channels/pizzapp_design