Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
🪐 The mysterious "dark flow" observed in the movement of galaxy clusters like Abell 3627 suggests that something unseen—possibly related to dark matter or dark energy—is pulling vast regions of the universe in the same direction. This large-scale motion, detected using X-rays from hot gas in clusters, remains unexplained by normal gravity and hints at the hidden forces shaping the cosmos beyond what we can directly observe. ✨
#darkmatter⚡#universe⚡#galaxyclusters⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Deep in the Coma Cluster, a packed group of over 1,000 galaxies, astronomers have measured how dark energy—a mysterious force causing the universe to expand faster over time—stretches the space between galaxies. Observations show that the distance between massive galaxies in the Coma Cluster grows not just from their own motion, but because dark energy is steadily pushing the entire cosmic structure apart. ✨
#darkenergy⚡#galaxyclusters⚡#cosmology⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The Bullet Cluster, found in the constellation Carina, provides some of the clearest real-world evidence for dark matter—a mysterious, invisible substance making up most of the universe’s mass. When two galaxy clusters crashed together, X-ray images showed that most of the visible matter stayed at the center, but gravity maps revealed most of the mass had moved ahead, proving something unseen—dark matter—was driving the collision's aftermath. ✨
#darkmatter⚡#galaxyclusters⚡#carina⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The cosmic microwave background holds a hidden fingerprint—tiny temperature fluctuations mapped in exquisite detail by satellites like Planck reveal how the first stars and galaxies, such as those in the ancient cluster Abell 2744, grew from initial small ripples in the early universe. These faint variations, just millionths of a degree, became the seeds around which all the cosmic structures we see today first assembled. ✨
#cosmicmicrowavebackground⚡#earlyuniverse⚡#galaxyclusters⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The cosmic microwave background contains faint "Sunyaev-Zel’dovich effects," which happen when the ancient microwave light passes through hot gas in galaxy clusters like the Bullet Cluster. This process boosts the energy of some photons (light particles), leaving tiny shadows in the background glow—allowing astronomers to map both distant galaxy clusters and the hot plasma between galaxies by studying these subtle marks in the oldest light in the universe. ✨
#microwave⚡#background⚡#galaxyclusters⚡#plasma⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels