Если запустить 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
🌍 The city of Venice, built on more than 100 small islands, uses a vast network of canals instead of streets. Its unique layout has helped it survive for centuries on shifting lagoon mud. ✨
#city⚡#canals⚡#adaptation⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌎 Amsterdam’s famous canal system was shaped by centuries of human engineering. Over 100 kilometers of canals were dug since the 17th century to manage water, transportation, and city expansion. Today, the city relies on more than 1,500 bridges to connect its neighborhoods. ✨
#Amsterdam⚡#canals⚡#engineering
👉subscribe Interesting Planet
👉more Channels
🌎 Amsterdam’s famous canal system shaped the city’s landscape but also lowered the local water table. Over 1,500 wooden bridge and building foundations are now monitored for rotting due to changing groundwater levels. ✨
#Amsterdam⚡#canals⚡#urbanization⚡#groundwater
👉subscribe Interesting Planet
👉more Channels