Если запустить 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
🌎 On the island of Märket in the Baltic Sea, the Finland-Sweden border cuts through a tiny lighthouse. The border was shifted in 1985 so both nations could share the landmark, creating a zigzag international line only 500 meters long. ✨
#borders⚡#geography⚡#lighthouse
👉subscribe Interesting Planet
👉more Channels
🌎 The Flannan Isles Lighthouse mystery remains unsolved: in December 1900, three lighthouse keepers disappeared from a remote Scottish island. No bodies or clues to their fate were found, and weather records suggest a sudden storm struck the area. The lighthouse was left locked, with meals untouched and logs stopping abruptly on December 15. ✨
#mystery⚡#lighthouse⚡#Scotland
👉subscribe Interesting Planet
👉more Channels