Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
🌎 Lurking in deep space, “dark matter” makes up about 27% of the universe, yet it remains invisible. Scientists infer its existence by observing gravity’s effects—like stars swirling faster than visible matter alone predicts. Its true nature is still unknown, but it outweighs all regular matter combined. ✨
#space⚡#astrophysics⚡#mystery
👉subscribe Interesting Planet
🌎 Mysterious dark matter makes up about 27% of the universe, but it does not emit or absorb light, making it invisible. Scientists detect dark matter only through its gravitational effects on galaxies and galaxy clusters. The leading candidates for dark matter particles are called WIMPs—Weakly Interacting Massive Particles. ✨
#space⚡#universe⚡#astrophysics
👉subscribe Interesting Planet
👉more Channels
🌎 Gamma-ray bursts are the most energetic explosions in the universe, releasing in seconds as much energy as the Sun emits over its entire 10-billion-year lifespan. They are detected by satellites as brief flashes of gamma radiation, and are thought to result from collapsing massive stars or merging neutron stars. ✨
#space⚡#gamma⚡#astrophysics
👉subscribe Interesting Planet
👉more Channels
🪐 In the spiral galaxy NGC 4993, scientists observed a gamma-ray burst, GRB 170817A, that arrived just 1.7 seconds after gravitational waves from the merger of two neutron stars—ultra-dense stellar remnants. This remarkable event marked the first time both gravitational waves and a gamma-ray burst were detected from the same source, giving astronomers an unprecedented, multi-messenger view of a cosmic collision. ✨
#gamma⚡#astrophysics⚡#neutronstars⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 In 2022, the Event Horizon Telescope captured the first radio image of the supermassive black hole at the center of our galaxy, Sagittarius A*, revealing a glowing ring of hot gas swirling around the event horizon—the point beyond which nothing can escape. This image confirmed decades of theory about black holes and showed that matter falling in forms a bright, lopsided halo just outside the black hole’s shadow, unlocking new clues about how these cosmic giants really behave. ✨
#blackholes⚡#SagittariusA⚡#astrophysics⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The star HE 0107-5240, found in the constellation Phoenix, is one of the most metal-poor stars ever discovered, meaning it contains almost no elements heavier than hydrogen and helium. This rare "primordial" star likely formed from the material left over after the very first stars died, making it an ancient relic that helps scientists study the universe's earliest generations of stars. ✨
#unusualstars⚡#primordialstars⚡#astrophysics⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The spiral galaxy Messier 83 has hosted more recorded gamma-ray bursts than almost any spiral galaxy nearby, becoming a hotspot for these mysterious explosions. Gamma-ray bursts are split-second flashes of the universe’s most energetic light, and their frequent appearance in Messier 83 helps scientists study how massive stars can end their lives in extreme, spectacular fashion. ✨
#Messier83⚡#gamma⚡#astrophysics⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The pulsar PSR J0437−4715, located about 500 light-years away in the constellation Pictor, spins nearly 174 times per second and is famous for its near-perfect "cosmic clock" precision. This ultra-stable pulsar allows astronomers to test the fundamental laws of physics and even hunt for elusive gravitational waves by tracking the tiny variations in its radio pulses over many years. ✨
#pulsars⚡#Pictor⚡#astrophysics⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
What If The Universe DID NOT Start With The Big Bang?
@PBS Space Time
👉 Head to https://brilliant.org/spacetime/ for a 30-day free trial + 20% off your annual subscription
#YouTube#liked#Black_Holes#Black_Hole#Black_Hole_Physics#Space#Outer_Space#Physics#Astrophysics#Quantum_Mechanics#Space_Physics#PBS#Space_Time#Time#PBS_Space_Time#Matt_O_Dowd#Einstein#Einsteinian_Physics#General_Relativity#Special_Relativity#Dark_Energy#Dark_Matter#The_Universe#Math#Science_Fiction#Calculus#Maths#Holographic_Universe#Holographic_Principle#Rare_Earth#Anthropic_Principle#Weak_Anthropic_Principle#Strong_Anthropic_Principle