Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
#quoteoftheday
💬“If you are not embarrassed by the first version of your product, you launched too late.” — Reid Hoffman, LinkedIn co-founder
🚀 While you are redesigning your logo for the tenth time, someone else is already monetizing their product at the MVP stage.
Follow Startup Base to stay updated on startups, opportunities, and the latest trends.
@startupbaseuz
LinkedIn | Facebook | Instagram | Website
#quoteoftheday
💬“Agar mahsulotingizning birinchi versiyasidan uyalmasangiz, siz uni juda kech ishga tushiribsiz”—Rid Hofman, LinkedIn asoschilaridan biri
🚀Siz logotipni o‘ninchi bor o‘zgartirayotganingizda, kimdir allaqachon mahsulotini MVP’da pullayapti.
Startaplar, ularga oid imkoniyatlar va trendlardan xabardor bo‘lish uchun Startup Base’ni kuzatib boring.
@startupbaseuz
LinkedIn | Facebook | Instagram | Website
☀️#Quoteoftheday
😇“Don't let yesterday take up too much of today.”
- Will Rogers
❤️@QuotesPoint
✅@Quotes_Positive_Inspirational
✔️@Quotes_Motivational_Inspiring
☀️#Quoteoftheday
😇“You cannot protect yourself from sadness without protecting yourself from happiness.”
- Jonathan Safran Foer
❤️@QuotesPoint
✅@Quotes_Positive_Inspirational
✔️@Quotes_Motivational_Inspiring
☀️#Quoteoftheday
😇“It's up to you how far you go. If you don't try, you'll never know!”
- Merlin, "Sword in the Stone"
❤️@QuotesPoint
✅@Quotes_Positive_Inspirational
✔️@Quotes_Motivational_Inspiring
☀️#Quoteoftheday
😇“Pursue the things you love doing and then do them so well that people can’t take their eyes off of you.”
- Maya Angelou
❤️@QuotesPoint
✅@Quotes_Positive_Inspirational
✔️@Quotes_Motivational_Inspiring
☀️#Quoteoftheday
😇“This is your life. Do what you love, and do it often.”
- Holstee Manifesto
❤️@QuotesPoint
✅@Quotes_Positive_Inspirational
✔️@Quotes_Motivational_Inspiring
☀️#Quoteoftheday
😇“Focus is the art of knowing what to ignore.”
- James Clear
❤️@QuotesPoint
✅@Quotes_Positive_Inspirational
✔️@Quotes_Motivational_Inspiring
☀️#Quoteoftheday
😇“Always remember that the future comes one day at a time.”
- Dean Acheson
❤️@QuotesPoint
✅@Quotes_Positive_Inspirational
✔️@Quotes_Motivational_Inspiring