Если запустить 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 Patagonian "stone flower" fungus, living on roots in arid South America, mimics pebbles to avoid predation. Its camouflaged fruiting bodies slowly absorb moisture and burst after rare rains, releasing clouds of spores across the steppe. ✨
#fungus⚡#camouflage⚡#Patagonia
👉subscribe Interesting Planet
🌎 The Devil’s Cigar is a rare fungus found only in parts of Texas and Japan. When it opens, it releases visible clouds of spores with a faint hissing sound—one of the few mushrooms that “smokes” as it spreads its seeds! ✨
#fungus⚡#nature⚡#Texas
👉subscribe Interesting Planet
🌎 The leafcutter ant creates underground gardens by carrying fresh leaves to feed a special fungus, which is their true food. This farming partnership has evolved over millions of years, making these ants nature’s original farmers long before humans. ✨
#ants⚡#fungus⚡#agriculture
👉subscribe Interesting Planet