Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
🌴 Maldives Atolls — a natural wonder created from coral reefs and the crystal-clear waters of the Indian Ocean 🌊🐠
✨ The Maldives Atolls are the lowest-lying country in the world. They consist of hundreds of coral islands scattered over an area of more than 90,000 km² 🏝. This archipelago is a diver's dream 🤿 and a paradise for snorkeling enthusiasts
#Maldives | @voyage
🌴 Vaavu Atoll – a Maldivian paradise! 🐠
Seclusion in nature, comfort, and a stunning underwater world make this the perfect spot for both relaxation and adventure!
✨
#Maldives | @voyage
🌴 Vaavu Atoll – a Maldivian paradise! 🐠
Seclusion in nature, comfort, and a stunning underwater world make this the perfect spot for both relaxation and adventure!
✨🌊
📏
📏
📏
📏
📏
📏
📏
📏
#Maldives | @voyage
🌴 Maldives Atolls — a natural wonder created from coral reefs and the crystal-clear waters of the Indian Ocean 🌊🐠
✨ The Maldives Atolls are the lowest-lying country in the world. They consist of hundreds of coral islands scattered over an area of more than 90,000 km² 🏝. This archipelago is a diver's dream 🤿 and a paradise for snorkeling enthusiasts 🐬
📏
📏
📏
📏
📏
📏
📏
📏
#Maldives | @voyage
🌴 Vaavu Atoll – a Maldivian paradise! 🐠
📏
📏
📏
📏
📏
📏
📏
📏
Seclusion in nature, comfort, and a stunning underwater world make this the perfect spot for both relaxation and adventure!
✨🌊
📏
📏
📏
📏
📏
📏
📏
📏
#Maldives🇲🇻@voyage
🌴 Vaavu Atoll – a Maldivian paradise! 🐠
📏
📏
📏
📏
📏
📏
📏
📏
Seclusion in nature, comfort, and a stunning underwater world make this the perfect spot for both relaxation and adventure!
✨🌊
📏
📏
📏
📏
📏
📏
📏
📏
#Maldives🇲🇻@voyage
🌊 Shipwreck in Keyodhoo – the pearl of Vaavu Atoll!
🟠This sunken treasure lures divers from all over the world. Explore the deep and witness the magic of the underwater realm! 🐠🤿
📏
📏
📏
📏
📏
📏
📏
📏
#Maldives🇲🇻@voyage