Is it safe to mix green threads and native threads in the same python process?
This gevent < 1.0
is most likely a bad idea since it is libevent
not thread safe. You might be fine if you make sure that OS threads never interact with libevent
... But it can be tricky, and errors caused by libevent
lack of thread safety don't seem fun to debug.
It does gevent >= 1.0
use however libev
, which is completely thread safe. So (as far as I can tell) there is no problem mixing green streams and OS streams.
source to share
gevent provides monkey patching capabilities for threads.
Greenlets only switch to each other within the same stream, so one green thread will be completely separate and without communication with the outside world.
I would not suggest using multiple streams of green until you have shown that you need to get the job done.
source to share