Skip to content

Add child_exit() callback to configuration - #1394

Merged
benoitc merged 3 commits into
benoitc:masterfrom
jonashaag:master
Jan 27, 2017
Merged

benoitc merged 3 commits into
benoitc:masterfrom
jonashaag:master

Conversation

@jonashaag

Copy link
Copy Markdown
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

benoitc commented Nov 21, 2016

Copy link
Copy Markdown
Owner

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

@jonashaag

jonashaag commented Nov 21, 2016 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor Author

Rebased to latest master

@berkerpeksag

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
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