I understand blocking code is a sin when it comes to event loops (i.e. NodeJS), but what about with greenlets (which I believe are green threads)? Is there an issue running code that calls blocking functions?
Share
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.
Greenlets themselves without an event loop as provided by gevent are very primitive. A blocking call from within one greenlet will block all greenlets since greenlets alone have no capability to yield on IO operations, and no scheduler. Gevent’s monkey-patching of socket and file IO is generally enough to enable non-blocking IO even with databases provided that the database library is written in python and uses sockets. Or alternately you can patch the library yourself.