Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
Let’s unlock all your Rat-Dex discoveries! Spot the signs early so we can stop them before they multiply. Help your neighbourhood stay rat-free by reporting signs of rat activity through the OneService app. #KeepSGClean
Don’t dump furniture at void decks or common areas.
🏢 HDB → Contact your Town Council
🏠 Private estate → Contact a public waste collector
Bulky items deserve proper disposal—keep our shared spaces safe & clean 🌍💚
#KeepSGClean
Cups and containers left behind in our shared spaces can trap water and turn into mozzie breeding spots. Pack up your litter, throw them into the bin and #KeepSGClean!
High-rise litter isn’t just messy; it’s dangerous. Let’s keep our shared spaces safe and clean. If you spot litterbugs, report them via the OneService app with details like date, time and location.
#KeepSGClean
Barbecue parties are fun, but piles of litter after aren’t. Food scraps & waste attract pests and make shared spaces unpleasant.
Let’s do our part and bin our waste. Spot someone leaving a mess? Report via the OneService app with date, time & exact location. Let’s keep our chill spots truly chill! #KeepSGClean
The food slapped 😋, but your leftovers? Not so much. Improper disposal of food waste = pests, smells, and fines up to $2,000. Let’s clear our mess before we leave and report littering via the OneService app with details such as date, time and precise location. #KeepSGClean
Your game might be 🔥 but leaving trash behind in public sports facilities is a major foul. Offenders can be fined up to $2,000 for first-time littering.
If you spot litterbugs, report them via the OneService app with details such as date, time and precise location. Let's keep our public sports facilities clean for everyone's game! #KeepSGClean
Pests, like rats, love their new homes within bulky waste. Do you? 🐀
To rid them of their new homes, keep public spaces clear of food and clutter!
HDB: Contact your Town Council
Private homes: Engage licensed collector 👉go.gov.sg/licensed-waste-collectors
Spot bulky waste left in common areas? Report via the OneService app with details such as date, time and precise location (block stack or column). Together, let’s #KeepSGClean!
Clean spaces protect our peace of mind ✨ Dispose of waste responsibly and help keep our shared areas uplifting for all.
Witness littering? Report it via the OneService app with details such as date, time and precise location. Together, let’s #KeepSGClean!