Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
🌍 The world’s shortest river, the Roe River in Montana, flows only about 61 meters from its source to its mouth. Despite its tiny length, it’s officially recognized as a river. ✨
#rivers⚡#hydrology⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 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🌍
🌍 The Amazon River’s water travels over 6,400 kilometers from Andes glaciers to the Atlantic, but some of its rain comes from clouds recycled multiple times through plant evaporation along the journey. ✨
#hydrology⚡#rivers⚡#rainforest⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Rivers in the Amazon basin recycle rainwater so efficiently that a single water droplet may fall as rain and evaporate back into the sky up to seven times before leaving the forest. ✨
#hydrology⚡#rainforest⚡#rivers⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 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
🌍 Water trapped as snow and ice in the Himalayas slowly melts each spring, feeding rivers that bring life to billions across Asia. This seasonal meltwater is key to the region’s water cycle. ✨
#hydrology⚡#rivers⚡#glaciers⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Some of the world’s longest underground rivers are hidden in karst landscapes. These rivers can travel for dozens of kilometers beneath the surface before emerging in springs or caves. ✨
#caves⚡#karst⚡#hydrology⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Atmospheric rivers—narrow bands of moisture in the sky—can carry more water than the Amazon River. When these “rivers in the air” hit land, they unleash heavy rains and reshape water cycles. ✨
#hydrology⚡#rainfall⚡#climate⚡#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🌍
🌍 Recent satellites can map changes in Earth's gravity from space. This helps track shifting water underground after floods or droughts, revealing hidden changes on a continental scale. ✨
#remote-sensing ⚡#satellites⚡#hydrology⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels