Eventlet vs Greenlet vs gevent?
24,300
- 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.
Related videos on Youtube
Author by
mehdy
I started playing with code when I was 10 and I’ve been enchanted with software since then. I am super-passionate about software engineering, startups, and leadership. I spend a lot of time reading books and articles, watching tech talks, and experimenting on these subjects.
Updated on February 11, 2020Comments
-
mehdy over 4 years
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.
-
Mahdi Zareie about 8 yearsreading this blog post very carefully might help blog.gevent.org/2010/02/27/why-gevent
-
Wavesailor almost 5 yearsSee this discussion for detailed explanation: stackoverflow.com/a/32936484/312089
-
-
Cees Timmerman over 5 yearsSo much for "There should be one-- and preferably only one --obvious way to do it.". I'd use
multiprocessing
. -
onlinejudge95 over 2 yearsWait what!! If it is I/O bound task then using multiprocessing is just a waste of resources isn't it, as other cores can be used for several other processes
-
temoto over 2 years@onlinejudge95 when a thread/process blocks on I/O, OS would use core for others. It's less efficient than epoll/kqueue/etc, but does not stall. It's actually OK approach up to around 200 threads.