Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
🌎 Australian megafauna like Diprotodon, the largest marsupial ever, disappeared about 46,000 years ago. These giant wombat relatives weighed up to 2,750 kilograms. The cause of their extinction is debated—some studies suggest climate shifts, while others blame human hunting. Diprotodon fossils have been found at over 100 sites across Australia. ✨
#extinctanimals⚡#megafauna⚡#paleontology
👉subscribe Interesting Planet
👉more Channels
🌎 The mysterious extinction of the “Siberian unicorn,” or Elasmotherium sibiricum, puzzles paleontologists. This massive Ice Age mammal, related to modern rhinos, had a large forehead horn and grazed Eurasian steppes. DNA studies show it survived until about 39,000 years ago—much later than once thought. ✨
#extinctanimals⚡#paleontology⚡#iceage
👉subscribe Interesting Planet
👉more Channels
🌎 The woolly rhinoceros, Coelodonta antiquitatis, roamed Ice Age Eurasia with a thick fur coat and massive horn. Fossils found in Siberian permafrost show it survived extreme cold; its extinction about 14,000 years ago is linked to climate warming and human hunting. ✨
#extinctanimals⚡#paleontology⚡#iceage
👉subscribe Interesting Planet
👉more Channels
🌎 The giant short-faced bear, Arctodus simus, roamed North America during the last Ice Age. Standing up to 1.5 meters at the shoulder, it was one of the largest terrestrial mammalian carnivores ever, yet paleontologists debate if it was mainly a predator or a scavenger. Fossils suggest it vanished around 11,000 years ago, along with much other megafauna. ✨
#extinctanimals⚡#paleontology⚡#iceage
👉subscribe Interesting Planet
👉more Channels
🌎 The Siberian unicorn, or Elasmotherium, was a massive prehistoric rhinoceros with a single huge horn on its forehead. Fossils show it roamed Eurasia until about 39,000 years ago, much later than once believed. ✨
#extinctanimals⚡#paleontology⚡#iceage
👉subscribe Interesting Planet
🌎 The thylacine, or Tasmanian tiger, was a striped marsupial predator native to Australia and Tasmania. Despite reports of sightings, the species was declared extinct in 1936 after the last known individual died in captivity. Intensive searches and camera traps have never produced concrete evidence of survival, but mystery sightings continue to spark debate among biologists. ✨
#extinctanimals⚡#marsupials⚡#australia
👉subscribe Interesting Planet