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

Enhance multiprocess manager's log data #2484

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion uvicorn/supervisors/multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def join(self) -> None:
def pid(self) -> int | None:
return self.process.pid

@property
def exitcode(self) -> int | None:
return self.process.exitcode


class Multiprocess:
def __init__(
Expand Down Expand Up @@ -167,13 +171,20 @@ def keep_subprocess_alive(self) -> None:
if process.is_alive():
continue

exitcode = process.exitcode
process.kill() # process is hung, kill it
process.join()

if self.should_exit.is_set():
return # pragma: full coverage

logger.info(f"Child process [{process.pid}] died")
signal_name = None
if exitcode is not None and exitcode < 0:
try:
signal_name = signal.Signals(-exitcode).name
except ValueError: # pragma: no cover
pass
Comment on lines +185 to +186
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do we have this?

logger.info(f"Child process [{process.pid}] died", extra={"exitcode": exitcode, "signal_name": signal_name})
process = Process(self.config, self.target, self.sockets)
process.start()
self.processes[idx] = process
Expand Down
Loading