-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Evaluate support for preload and monkey-patching #1566
Comments
I think the new gc.freeze api would be of use, more details in the cpython pull request and issue ticket; |
As of gevent 1.3a1 you get the following
|
The warning was added as a result of gevent/gevent#1016. Basically, importing |
@tilgovi how do you think we can progress on that topic? Would be good to draft some roadmap for it. In the mean time I would postpone it for the next release if you're OK? |
I'm okay to postpone. @jamadden do you think we should try importing gevent earlier? What has been your experience? If I remember correctly, I've seen code you shared from a project where you monkey-patch before loading Gunicorn as a custom application. |
Yes, we use a setuptools console entry point to first monkey-patch, then load gunicorn's own console entry point, thus ensuring that everything is monkey-patched before any application code is pre-loaded. It works very well for us. |
postponing to 20.1 let's try to find a solution for it :) |
So back on this topic since someone reported on irc he hit the error. The problem I see in monkey patching during preload is that it would make the socket unblocked in the arbiter, which is not really wanted. We should make sure to use the unpatched module/function in the arbiter. |
Does the arbiter perform any blocking calls on the socket? If not, do we care if the socket is patched in the arbiter? Mostly, the arbiter just passes the socket to workers. |
The arbiter itself rely on a blocking behaviour for select and signaling. Also it's safer to bind the socket in blocking mode. This is why it's discouraged to patch outside of a worker. Also in term of design i am thinking it's better to have the arbiter isolated from the application logic. I am thinking there is a way to make sure the arbiter is always the unpatched module/functions. Kind of patching before the patch happen so w keep original modules available for our own usage. This would allows gevent, eventlet but also any other lib to do whatever they want. cc @jamadden |
I'm not sure I see a danger anywhere in the way the arbiter uses sockets or signals. If I remember correctly, @jamadden has experience patching the arbiter early with gevent without issue. |
Yes, we still patch before running any gunicorn code and haven't encountered any issues as far as I know. gunicorn master and workers all respond to signal as expected, requests are delivered as expected, etc. We recently enabled SO_REUSEPORT and everything continued to works. |
FWIW, our organization patches like this for a half-dozen microservices in production and we have not run into any issues with it. |
I'm not against patching it sooner in the case of preload case. Maybe indeed it won't arm to just patch it, so why not trying it in a branch for the next 2 days (so we can release 20.0.1 on thursday). I think it requires the following changes:
Do you see anything else? |
I think we have some minor issues to fix for 20.0.1, but should defer this to 20.1 or 21, if we think it's at all risky. I don't think we should change any APIs, even internal APIs, in a patch release. |
@tilgov agree, the change it planned to the milestone 20.1. Btw There is a 20.0.1 milestone created, so if something is missing please add it to it :) |
So... how is it going with the |
Is supporting preload with monkey-patching planned for any upcoming release ? |
There is no planning really. If there is a merged PR it will be in. If someone asks I might make a release. |
no activity since awhile. closing feel free to create a new ticket if needed. |
Extending discussion from #927, it would be good if, for R20, we can take a firm stance on whether gevent/eventlet are supported with the preload option. This evaluation will probably depend on our approach to multiprocessing under Windows, as well as the state of gevent/eventlet and how we plan to maintain worker classes going forward.
The text was updated successfully, but these errors were encountered: