Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
🌍 Asia is the largest continent, but the Pacific Ocean is even bigger—its area almost doubles that of all land in Asia, making it Earth’s vastest single geographic feature. ✨
#continents⚡#oceans⚡#earth⚡#geography⚡#nature
👉subscribe Amazing Geography
👉more Channels
🌍 The Pacific Ocean is wider than the entire Moon. At its widest, it stretches over 19,000 kilometers from Asia to the Americas—more than the Moon’s diameter of 3,474 kilometers. ✨
#continents⚡#oceans⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The boundary between Europe and Asia runs mostly along the Ural Mountains and Ural River. This dividing line is not marked by ocean or sea, making it the only major continental border mostly on land. ✨
#continents⚡#borders⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Africa is the only continent that stretches from the northern temperate zone all the way to the southern temperate zone, crossing both the Equator and the prime meridian. ✨
#continents⚡#Africa⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The Atlantic Ocean is expanding as the Americas move away from Europe and Africa. This slow drift adds about 2.5 centimeters of new seafloor every year along the Mid-Atlantic Ridge. ✨
#continents⚡#ocean⚡#geology⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Mid-Atlantic Ridge runs down the center of the Atlantic Ocean, forming the world’s longest mountain chain—most of it hidden beneath the sea between continents. ✨
#continents⚡#ocean⚡#geology⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Southern Ocean, officially recognized in 2021, surrounds Antarctica and connects the Atlantic, Pacific, and Indian Oceans, forming a unique ring of cold currents that help regulate Earth’s climate. ✨
#continents⚡#oceans⚡#climate⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The Atlantic Ocean is growing wider each year as the Americas slowly drift apart from Europe and Africa, adding about 2.5 centimeters annually—roughly the speed fingernails grow. ✨
#continents⚡#oceans⚡#tectonics⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The Eurasian and North American continents are moving apart by about 2.5 centimeters every year along the Mid-Atlantic Ridge, slowly widening the Atlantic Ocean over millions of years. ✨
#continents⚡#oceans⚡#tectonics⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Antarctica is the only continent entirely surrounded by ocean and is nearly twice the size of Australia. Its thick ice reflects sunlight, helping regulate Earth’s overall temperature. ✨
#continents⚡#oceans⚡#Antarctica⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 In prehistoric times, people migrated out of Africa in waves, eventually reaching every continent except Antarctica. This journey took tens of thousands of years and shaped human diversity. ✨
#migration⚡#history⚡#continents⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍