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

Suppress side-effects of signal propagation #2317

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

maxfischer2781
Copy link
Contributor

@maxfischer2781 maxfischer2781 commented Apr 26, 2024

Summary

This PR suppresses noise and dirt from signal propagation introduced in #1600.

  • Suppress tracebacks from worker/reload subprocesses on termination. These are triggered deep inside multiprocessing.process on any exception. Since the shutdown exception is expected, subprocesses spawned for workers/reload simply discard it.
  • Always run cleanup of unix domain sockets when the uvicorn.run exits. This would previously be skipped on forced shutdown.

Note: I was not able to reproduce #2281 / #2289 so I do not know if they are fixed by this. However, this fixes the various reports on those discussions/issues about tracebacks.


I do not have access to a Windows machine for testing so had to emulate it. It would be nice if someone can confirm that this works on Windows. A minimal repro is the program

# test.py
async def dummy_app(scope, receive, send): pass

run via

python -m uvicorn test:dummy_app --reload

@johanboekhoven kindly tested this on Windows.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
    • This change has no effect on behaviour, merely output.
  • I've updated the documentation accordingly.
    • This change has no effect on documented behaviour.

@maxfischer2781 maxfischer2781 changed the title Suppress side-effects of signal Suppress side-effects of signal propagation Apr 27, 2024
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.

Unexcepted behavior while reloading
1 participant