-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client cannot send with gunicorn gevent worker #123
Comments
Can you double check that gevent is working properly in your gunicorn+flask setup? zerorpc should definitively work in this case. zerorpc has its own wrapper integrating zmq with gevent, because of some sync/bug problems that were never resolved. But its very small and zerorpc definitively work with gevent. de rien :) |
I wrote a demo for this $ PYTHONPATH=. gunicorn client:app and visit the localhost website, and the app works fine. Here is the log:
And I switched to gevent worker by changing command to $ PYTHONPATH=. gunicorn -k gevent client:app when I visit the localhost website, the thread is blocked, and I didn't get the excepted response
|
Update: thanks! |
Hi, thanks for the throughout explanation. So it looks like monkey patching the threading module is not doing good on pyzmq. But hey its monkey patching, what did you expect ;) zerorpc itself is doing nothing wrong here, it uses pyzmq the way it should be used, and wraps it to work with the gevent loop. that's it. The problem lies definitively with monkey patching everything and pyzmq is then failing. pyzmq probably requires real native thread to perform some tasks because it likely blocks the threads. If it suddenly uses greenthreads, it will lock up the main thread ie: the whole process. That's what I bet, at least. Best, |
Is there a possible fix here? This issue is certainly a bug in pyzmq directly and not zerorpc, but given the way pyzmq.context is implemented, I don't see that this module can ever work with gevent and a modern version of pyzmq. |
@lordnynex see zeromq/pyzmq#765 for detail, it seems fixed in 15.2.0. I tested myself, in simple cases, it works with gevent monkey patch. So I think there might be something else in your code triggers the bug. I haven't use |
@faith0811 thank you for the links, very interesting. The latest version of pyzmq should handle the gevent monkey patching of the threading API. Few miscellaneous points:
|
Using latest version of zerorpc, I cannot send message to zerorpc server. The client is hosted in a web server (flask) running upon gunicorn with gevent worker.
It looks like that the thread is just blocked, and there is no response at all.
The client works after I change to gunicorn sync worker ( with no
-k gevent
).is this a problem of zerorpc(i saw zerorpc has implemented a gevent version of zeromq) or it is something wrong with gunicorn or i messed up with something?
Merci!
The text was updated successfully, but these errors were encountered: