Asyncio vs. Gevent [closed] Asyncio vs. Gevent [closed] python python

Asyncio vs. Gevent [closed]


"Simple" answer from real-world usage:

  1. Good thing about gevent — you can patch things, which means that you [theoretically] can use synchronous libraries. I.e. you can patch django.
  2. Bad thing about gevent — not everything can be patched, if you must use some DB driver that can't be patched, you're doomed
  3. Worst thing about gevent — it's "magical". Amount of effort required to understand what happens with "patch_all" is enormous, the same effort applies to finding/hiring new people for your dev team. What is even worse — debugging gevent-based code is hell. I'd say, pretty much the same hell, as callbacks, if not worse.

Later point is key, I think. Most underestimated thing in software engineering is that code is meant to be read, not written or run effectively (if later is the case, you'd rather switch from python to system-level language). Asyncio came with missing part for async programming — pre-defined and controlled context switch points. You actually writing sync code (i.e. you're not thinking about sudden thread switch, locks, queues, etc.), and using await ... when you know call is IO blocking, so you let event loop pick on something else, that is ready for CPU, and pick up current state later.

This is what makes asyncio so good — it's easy to maintain. The downside is that pretty much all "world" must be async too — DB drivers, http tools, file handlers. And sometimes you'll be missing libraries, that's pretty much guaranteed.