Стандартная библиотека asyncio это стандарт (начиная с Py3.4) для работы с асинхронным кодом. Но эта библиотека достаточно низкоуровневая, со своими проблемами, устаревшими подходами.
Чтобы исправить это, были созданы разные обертки и альтернативы с реализацией популярных инструментов и паттернов асинхронного программирования. Это такие библиотеки как:
- trio: улучшает корректность выполнения, не оставляя потерянных корутин при ошибках, то есть предлагает Structured Concurrency из коробки.
- curio: упрощение синтаксиса и читаемости кода, больше похоже на работу с потоками.
- anyio: универсальная обертка над asyncio или trio плюс множество вспомогательных инструментов.
anyio используется в FastAPI как основная библиотека для работы с асинхронным кодом и вызовом синхронного кода из асинхронного.
В общем, рекомендую почитать про возможности anyio, возможно вы более не будете использовать чистый asyncio в своих проектах)
Это совсем не значит что дефолтный asyncio плох, он тоже даёт достаточный для работы функционал и продолжает развиваться. Например, в версии 3.11 появились TaskGroup, с похожим на trio функционалом. Так что он тоже актуален, просто придется больше написать кода самостоятельно.
#libs#async
🪐 Magnetars like Swift J1822.3−1606, discovered in the constellation Sagittarius, create magnetic fields over a trillion times stronger than Earth's—so intense they can distort atoms and transform empty space itself into a strange state called a “quantum vacuum.” These extreme conditions make magnetars some of the most powerful natural magnets ever found, unleashing bursts of high-energy X-rays and gamma rays that briefly outshine everything nearby. ✨
#magnetar⚡#neutronstar⚡#extremes⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The magnetar PSR J1745−2900, found near the center of our Milky Way close to Sagittarius A*, showcases magnetic fields so intense they can disrupt atoms and twist space itself. Its field strength is estimated at over a quadrillion times higher than Earth's, making PSR J1745−2900 one of the most extreme magnets in the galaxy and a prime example of how magnetars stretch the laws of physics to their limits. ✨
#magnetar⚡#neutronstar⚡#extremes⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Deep in the constellation Carina sits the magnetar 1E 2259+586, a neutron star with a magnetic field so powerful—over 100 trillion times stronger than Earth's—that it can twist and shatter its own crust. When this happens, it releases bursts of high-energy X-rays and gamma rays, briefly outshining entire galaxies before fading back into cosmic silence. ✨
#magnetar⚡#neutronstar⚡#extremes⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 In the constellation Ophiuchus, the neutron star PSR J1846–0258 stunned astronomers when it suddenly switched from behaving like a typical pulsar—flashing regular radio waves—to emitting powerful X-ray bursts, a feature seen in "magnetars," which are neutron stars with ultra-strong magnetic fields. This rare identity shift blurs the line between two of the most extreme types of dead stars, revealing the unpredictable and mysterious nature of cosmic objects. ✨
#neutronstar⚡#magnetar⚡#phenomena⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The magnetar CXOU J171405.7−381031, found in the supernova remnant CTB 37B, is famous for its exceptionally strong magnetic field—over a thousand trillion times more powerful than Earth's. Such intense magnetism can twist the star’s crust, causing violent starquakes and bursts of high-energy radiation that briefly outshine everything else in its region of space. ✨
#magnetar⚡#supernova⚡#neutronstar⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 On August 27, 1998, astronomers detected a remarkable gamma-ray burst from the magnetar SGR 1900+14, located about 20,000 light-years away in the constellation Aquila. This event released more than a thousand times the energy of the Sun in just a fraction of a second, making it one of the brightest gamma-ray flashes ever recorded and proving that magnetars—neutron stars with ultra-strong magnetic fields—can unleash explosions powerful enough to briefly outshine entire galaxies. ✨
#gamma-ray-bursts ⚡#magnetar⚡#cosmic-explosions ⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 Deep in the constellation Vulpecula, the magnetar 1E 2259+586 unleashes magnetic fields so powerful—over 100 trillion times stronger than Earth's—that they can physically warp the star's crust. When these intense magnetic forces crack the surface, they release bursts of high-energy X-rays and gamma rays, briefly making the magnetar outshine every other X-ray source in its region of space. ✨
#magnetar⚡#neutronstar⚡#extrememagnetism⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The magnetar named J1745−2900, discovered near the center of our galaxy close to Sagittarius A*, has one of the most powerful magnetic fields ever measured—enough to disrupt radio signals and, in theory, even deform atoms into thin strings. This type of neutron star is so incredibly magnetic that its field would erase every credit card on Earth from a distance of half the Moon’s span, making J1745−2900 an extreme natural magnet impossible to recreate in any lab. ✨
#magnetar⚡#neutronstar⚡#extremespace⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The magnetar 1RXS J170849.0–400910, located about 18,000 light-years away in the constellation Ophiuchus, is known for its titanic magnetic field, which can reach over 100 trillion times the strength of Earth's. This intense magnetism is so powerful that it can twist the star's crust, triggering sudden bursts of X-rays and gamma rays—brief flashes that outshine entire regions of space before fading into darkness. ✨
#magnetar⚡#Xrays⚡#Ophiuchus⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels