Eventlet vs Greenlet vs gevent?

Question:

I’m trying to create a GUI framework that will have an event-loop. some threads to handle the UI and some for event handling. I’ve searched a little bit and found these three libraries and I’m wondering which one is better to use? what are the pros and cons?

I could use one of these three library or even create something for myself by using python threads, or concurrent library.

I would appreciate sharing any kind of experience, benchmark and comparison.

Asked By: mehdy

||

Answers:

  • You definitely don’t want greenlet for this purpose, because it’s a low level library on top of which you can create light thread libraries (like Eventlet and Gevent).
  • Eventlet, Gevent and more similar libraries provide excellent toolset for IO-bound tasks (waiting for read/write on file, network).
  • Likely, most of your GUI code will wait for other threads (at this point green/light/OS thread is irrelevant) to finish, which is a perfect target for above mentioned libraries.
  • All green thread libraries are mostly the same. Try all and decide which one suits your project best.
  • But also it’s possible that you’ll need to extract some things into a separate OS thread due to requirements of OS level GUI layer.
  • Considering that and better implementation of thread lock in Python3 you may want to just stick with native threading module if your application doesn’t need hundreds or more threads.
Answered By: temoto