Eventlet vs Greenlet vs gevent?

mehdy picture mehdy · Apr 25, 2016 · Viewed 19.6k times · Source

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.

Answer

temoto picture temoto · Apr 26, 2016
  • 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.