Если запустить 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
🌎 Off the coast of Australia, the mysterious "pink lakes" like Lake Hillier owe their color to the algae Dunaliella salina, which produce red pigments in salty environments. Lake Hillier’s pink hue remains stable even when bottled, due to the unique chemistry of its saline water. ✨
#ocean⚡#mystery⚡#algae
👉subscribe Interesting Planet
👉more Channels
🌎 Red tides sometimes turn the ocean a rusty red or brown—caused by massive blooms of algae packed with pigments. These blooms can release toxins that harm fish and even impact local air quality, making ocean color changes a sign of dramatic ecological shifts. ✨
#ocean⚡#algae⚡#pigments
👉subscribe Interesting Planet
🌎 Red rain fell in the Indian state of Kerala in 2001, coloring streets and clothing. Scientists found the cause was airborne spores from local algae cells. Some showers were bright red for up to two months. ✨
#phenomena⚡#weather⚡#algae
👉subscribe Interesting Planet
👉more Channels