|
|
|
|
|
by nerdwaller
2871 days ago
|
|
Having worked in asyncio for a bit I don’t entirely follow this (it truly could just be familiarity), very little of asyncio (especially post `async/await` were introduced in the language) is callback based and reads more procedural. Regarding generator coroutines it feels like a natural evolution of the language. Given that yield previously suspended the current function’s state providing value(s) to the closure, it only makes sense that yield (on the producer side)/await (on the consumer side) does the same thing but in an event loop based context. I can’t speak deeply enough about green threads, but from my understanding there’s much less magic (as you cite “explicit”) in an async/await world vs the magic (“implicit”) world of green threads. async def thing():
print(‘before’)
await asyncio.sleep(0)
print(‘after’)
Vs def thing():
print(‘before’)
gevent.sleep(0)
print(‘after’)
There’s nothing clear in the latter when something yields or otherwise passes control flow.Having worked in a few evented systems, I find the explicit shift to the runtime is valuable. |
|