Skip to content
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 child_exit() callback to configuration #1394

Merged
merged 3 commits into from
Jan 27, 2017
Merged

Conversation

jonashaag
Copy link
Contributor

This adds a child_exit() callback to the Gunicorn configuration that works similar to worker_exit() but is called in the master process instead of the child process.

I also added some basic unit tests for the both.

A change to how Worker.pid is implemented was necessary in order for it to be meaningful in the master process (it would always be the PID of the master process, no information given about the worker process).

Our need for this is prometheus/client_python#115

@benoitc
Copy link
Owner

benoitc commented Nov 21, 2016

I will look at the patch. For your case why don't you clean the data when the worker is spawned though?

@jonashaag
Copy link
Contributor Author

jonashaag commented Nov 21, 2016

For your case why don't you clean the data when the worker is spawned though?

We need the old worker's PID to do that

This is similar to worker_exit() in that it is called just after a
worker has terminated, but it's called in the Gunicorn *master* process,
not the *child* process.
@jonashaag
Copy link
Contributor Author

Rebased to latest master

@berkerpeksag
Copy link
Collaborator

Looks good to me too. It would be nice to add a versionadded directive. @benoitc and @tilgovi should it be 19.7 or 20?

(We also need to use the "squash and merge" button when we merge this.)

@jonashaag
Copy link
Contributor Author

(We also need to use the "squash and merge" button when we merge this.)

I deliberately split the changes into three commits to make them easier to understand

@jonashaag
Copy link
Contributor Author

Hey, what's the state of this? Is there anything I can do to have this merged?

@benoitc benoitc merged commit 21ffa92 into benoitc:master Jan 27, 2017
StephanErb added a commit to StephanErb/client_python that referenced this pull request Mar 21, 2017
We need to use the recently added Gunicorn `child_exited` callback in order to
correctly clean up after a segfaulted or OOM-killed worker (for details, see
benoitc/gunicorn#1394).
brian-brazil pushed a commit to prometheus/client_python that referenced this pull request Mar 21, 2017
We need to use the recently added Gunicorn `child_exited` callback in order to
correctly clean up after a segfaulted or OOM-killed worker (for details, see
benoitc/gunicorn#1394).
mjjbell pushed a commit to mjjbell/gunicorn that referenced this pull request Mar 16, 2018
Add child_exit() callback to configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants