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

Fix RuntimeError caused by logging in the SIGCHLD signal handler #2667

Conversation

BoasKluiving
Copy link

This PR is to fix an issue introduced by b695b49. This issue is also described in #2564. The problem is that we are logging something in the signal handler, which is not reentrant.

The issue occurs if Gunicorn happens to be logging something (for example here) and gets interrupted by SIGCHLD at that moment. This invokes the signal handler handle_chld() (here), which calls reap_workers().

reap_workers() however logs a warning here, causing the following RuntimeError:
RuntimeError: reentrant call inside <_io.BufferedWriter name='<stderr>'>

Operations on BufferedWriter are unfortunately not reentrant, so we can only fix this by (a) not logging in the signal handler or (b) only setting a flag in signal handler and do the processing later.

This PR fixes the problem by removing the log message in the signal handler.

@javabrett
Copy link
Collaborator

@BoasKluiving thanks for the PR. b695b49 was reverted by 76f8da2 having the same effect, so closing this PR.

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.

2 participants