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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
With
gevent < 1.0it is most likely a bad idea, aslibeventisn’t thread safe. You might be okay if you make sure that the OS threads never interact withlibevent… But that could be tricky, and bugs cause bylibevent‘s lack of thread safety don’t sound like any fun to debug.However,
gevent >= 1.0useslibev, which is entirely thread safe. So (as far as I can tell) there’s no problem mixing green threads and OS threads.