Firstly, is it safe to mix green threads such as eventlet or gevent with python native threads from the standard library, i.e. Lib/threading.py in the same python process?
Secondly, if it is safe, is it a bad idea?
With gevent < 1.0
it is most likely a bad idea, as libevent
isn't thread safe. You might be okay if you make sure that the OS threads never interact with libevent
… But that could be tricky, and bugs cause by libevent
's lack of thread safety don't sound like any fun to debug.
However, gevent >= 1.0
uses libev
, which is entirely thread safe. So (as far as I can tell) there's no problem mixing green threads and OS threads.