Taras Voinarovskyi
Taras Voinarovskyi
Why can be bad in some cases:
PyPy's
greenlet
Stackless tasklet
coroutines
tasks
PEP 492 -- Coroutines with async and await syntax
async def my_coroutine():
res = await io_operation()
async with my_async_context():
print("In context")
async for x in my_asyn_iter():
print("Yielded", x)
yield "We can even do async generators"
import time
class Future:
def __await__(self):
sleep_time = 0
while True:
sleep_time = yield f"Sleeping for {sleep_time}s"
time.sleep(sleep_time)
async def coro():
await Future()
c = coro()