Если запустить 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 1976, NASA’s Viking 1 lander touched down on Mars and conducted the first experiments specifically designed to search for signs of life on another planet. The Viking lander analyzed Martian soil for chemical reactions that might indicate life, and while some results were intriguing, no definitive evidence of Martian microbes was found, keeping the mystery of aliens alive on the Red Planet. ✨
#Mars⚡#Viking⚡#extraterrestrial⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries