Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
🌍 Water molecules in the ocean today could have once traveled through glaciers, rivers, or clouds—completing a global journey called the water cycle that never truly ends. ✨
#hydrology⚡#watercycle⚡#earth⚡#geography⚡#nature
👉subscribe Amazing Geography
👉more Channels
🌍 Some of the water we drink today has cycled through dinosaurs and ancient forests. Water molecules can take thousands of years to complete a single journey through the global water cycle. ✨
#hydrology⚡#watercycle⚡#earth⚡#geography⚡#nature
👉subscribe Amazing Geography🌍
🌍 Water in the atmosphere is always on the move—at any moment, only about 0.001% of Earth’s water is in the air as vapor, yet this tiny fraction drives all rain, snow, and weather worldwide. ✨
#hydrology⚡#watercycle⚡#atmosphere⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Water vapor in the air isn’t just invisible—it’s crucial for moving energy around the planet. When vapor condenses into clouds, it releases heat that drives weather systems worldwide. ✨
#hydrology⚡#atmosphere⚡#watercycle⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 About 90% of the water exchanged in the global water cycle happens over the oceans, not land. Yet this invisible ocean-to-sky movement powers most of the world’s rainfall. ✨
#hydrology⚡#watercycle⚡#oceans⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Just 0.001% of all water on Earth is found in rivers, lakes, and the atmosphere. The vast majority is locked away in ice sheets, glaciers, or underground where we rarely see it. ✨
#hydrology⚡#watercycle⚡#freshwater⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The water cycle, or hydrologic cycle, constantly moves water through evaporation, condensation, and precipitation, powering rivers, forming clouds, and shaping climates worldwide. ✨
#watercycle⚡#evaporation⚡#precipitation⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍