Если запустить REPL с модулем asyncio, то вы входите в особый асинхронный REPL.
user@host:~$ python -m asyncio
asyncio REPL 3.12.7 ...
Use "await" directly instead of "asyncio.run()".
>>> import asyncio
>>>
В этом режиме
- создаётся и настраивается event loop
- уже импортирован asyncio
- работает await на верхнем уровне
То есть такая команда сработает без ошибок!
await asyncio.sleep(3)
Удобно для тестирования асинхронных функций без создания ивентлупов и остальной обвязки.
Работает в: 3.8+
#tricks#async
🪐 In the constellation Hydra, astronomers have found R Hydrae, a star that pulses in brightness over a period of about 385 days. This "Mira variable" expands and contracts like a cosmic heartbeat, changing size and light output as it nears the end of its life, giving scientists clues about the future fate of our own Sun. ✨
#stars⚡#hydra⚡#pulsation⚡#nasa⚡#galaxy⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 In the constellation Vela, the star system HD 74423 displays an unusual cosmic phenomenon: its shape is teardrop-like rather than round, caused by the powerful gravitational pull of a nearby red dwarf companion. This distortion leads to "heartbeat" pulsations—brightenings and dimmings in rhythm with the stars’ orbits—making HD 74423 the first known one-sided pulsating star in our galaxy. ✨
#Vela⚡#heartbeatstars⚡#pulsation⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries