-
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
Add field arbiter.stopping #2944
base: master
Are you sure you want to change the base?
Conversation
@@ -63,6 +63,7 @@ def __init__(self, app): | |||
self.reexec_pid = 0 | |||
self.master_pid = 0 | |||
self.master_name = "Master" | |||
self.stopping = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure but may be is_stopping
more better name for this, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably yes... but I'll wait for the more fundamental problems that @benoitc raised before dealing with the details
I don't understand the use case. Can you provide an example? Why not simply add a hook executed when stopping? |
I think I did? The code I have provided will not work pre-PR (it depends on
That depends on your definition of "simply"... in my world adding a flag is more simple than a hook which executes arbitrary code. Having said that such arbitrary code could always include the setting-of-the flag so it would indeed be a solution. And I can also see how it could be more simple in a world where all configuration is done with hooks (at least it would be more consistent). |
perhaps this was the bit you missed? I have to admit I did not write down at the time what the exception was and do not remember it exactly, but I can imagine that closing sockets more than once (which is what |
related to #2884 I think we could have a generic way to allows the developer to define the behaviour when an instruction to stop Gunicorn is received. Let's keep the PR for now to get is as a basis to troduce an |
Motivation: I'm running some code in which the server is stopped[1]. I would like to do this only when the server is not already in a "stopping" state. Because my code is tied to an event, it could be called "at any time", either because someone else already called
server.stop
, or in the example below even because our own call toserver.stop
caused the workers to quit. In any case, repeated calls toserver.stop
are undesirable because repeated execution of that method will lead to an exception. I'd like to instead check whether we're currently in the process of stopping.(my current solution works around the lack of
self.stopping
by monkey-patchingdef stop
, but this is ugly)[1] in this case the server is stopped whenever a child is stopped, but this is not material to the issue.