Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
🪐 In the galaxy M81, located about 12 million light-years away, scientists have detected mysterious, isolated fast radio bursts—brief blasts of radio waves lasting just milliseconds but releasing as much energy as hundreds of millions of suns. These puzzling signals are so powerful and short-lived that pinpointing their exact origins within M81 has become a cosmic detective story, as astronomers use radio telescopes to track each fleeting flash from this nearby spiral galaxy. ✨
#fastbursts⚡#galaxies⚡#phenomena⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 In 2022, astronomers used the Hubble Space Telescope to identify a fast radio burst originating from a galaxy called WISEA J071634.59–190039.2, located about 6 billion light-years from Earth. This pinpointed location helps scientists study the environments where these ultra-short, powerful flashes of radio energy are born, revealing new clues about the mysterious origins of fast radio bursts across the cosmos. ✨
#fastbursts⚡#hubble⚡#galaxies⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 In the galaxy dubbed "The Whale" (NGC 4631), astronomers have detected a barrage of fast radio bursts—ultra-brief, intense flashes of radio energy—coming not from the center, but from the galaxy’s outer regions. These mysterious signals last just milliseconds but shine as brightly as billions of suns, making NGC 4631's outskirts a surprising hotspot for one of space’s most powerful, fleeting phenomena. ✨
#fastbursts⚡#galaxies⚡#radioastronomy⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 In 2020, astronomers traced a fast radio burst called FRB 200428 to our own Milky Way and found it came from a magnetar named SGR 1935+2154. This was the first time a fast radio burst—a super-short flash of radio energy from space—was directly linked to a known type of object, showing that magnetars, which are neutron stars with extremely strong magnetic fields, can produce these intense cosmic signals. ✨
#fastbursts⚡#magnetars⚡#milkyway⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 In 2023, astronomers using the Australian Square Kilometre Array Pathfinder (ASKAP) discovered a repeating fast radio burst called FRB 20220912A in the spiral galaxy ESO 601-G024, about 1 billion light-years away. Unlike other repeating bursts, FRB 20220912A's signal showed a strong "downward drift" in frequency, meaning each pulse slowly slid to lower radio frequencies over just a few milliseconds, helping scientists trace the physical processes at the burst's origin. ✨
#fastbursts⚡#radio⚡#spiralgalaxy⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Among the strangest discoveries in astronomy are fast radio bursts (FRBs) emerging from the spiral galaxy NGC 253, also known as the Sculptor Galaxy. In 2022, scientists detected a repeating FRB source here—brief flashes of radio energy lasting just milliseconds and releasing more power than the Sun generates in years—making NGC 253 a new hot spot in the ongoing quest to understand these mysterious cosmic signals. ✨
#fastbursts⚡#sculptorgalaxy⚡#radioastronomy⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 In 2023, the Australian Square Kilometre Array Pathfinder detected an unusual pattern in fast radio bursts coming from the spiral galaxy NGC 2082, with several bursts arriving from different regions within the same galaxy. These millisecond flashes of radio energy, each releasing as much power as hundreds of millions of suns, show that multiple mysterious sources can exist in a single galaxy, deepening the puzzle of what causes these intense cosmic signals. ✨
#fastbursts⚡#ngc2082⚡#radioenergy⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels