Skip to content

Commit

Permalink
arbiter: don't log messages when handling SIGCHLD
Browse files Browse the repository at this point in the history
Fixes benoitc#2816

Logging stuff in a signal handler cannot work and thus must not be done.
https://docs.python.org/3/library/logging.html#thread-safety
  • Loading branch information
hydrargyrum authored Sep 5, 2023
1 parent ab9c830 commit 237d58e
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions gunicorn/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,27 +532,6 @@ def reap_workers(self):
reason = "App failed to load."
raise HaltServer(reason, self.APP_LOAD_ERROR)

if exitcode > 0:
# If the exit code of the worker is greater than 0,
# let the user know.
self.log.error("Worker (pid:%s) exited with code %s.",
wpid, exitcode)
elif status > 0:
# If the exit code of the worker is 0 and the status
# is greater than 0, then it was most likely killed
# via a signal.
try:
sig_name = signal.Signals(status).name
except ValueError:
sig_name = "code {}".format(status)
msg = "Worker (pid:{}) was sent {}!".format(
wpid, sig_name)

# Additional hint for SIGKILL
if status == signal.SIGKILL:
msg += " Perhaps out of memory?"
self.log.error(msg)

worker = self.WORKERS.pop(wpid, None)
if not worker:
continue
Expand Down

0 comments on commit 237d58e

Please sign in to comment.