-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Unexpected behavior when handling signals #12830
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
Comments
I came here to report the same thing and found this related issue. I have a tool which sends Reproducer:
I echo the need for an All sorts of python tools (e.g. coverage tools) use signals for various purposes. |
We need to be able to clean up resources, such as temporary virtual environments. We could consider changing our strategy there, but it's complicated. Discussed previously at #3095 |
How were you terminating your processes? |
This is a bit complicated. 😬 We also found some work arounds, for example doing something else before we disconnect in Fabric, like Thank you for taking care of this! (#13017) |
I think this is the proper configuration, fwiw. If you don't want other children to receive the signal, you can change their PGID with But yeah, it's complicated. Hopefully forwarding the signals solves most of these problems. |
Just wanted to mention that signals are now flowing correctly via |
Summary
Hello,
first off, I wasn't sure how to tag this; this is a bug report about unexpected behavior, with a feature request latched on as a solution proposal.
We recently switched our projects to use
uv
and ran into issues where on our servers Python processes would stay alive in the background after deploying new versions of our software onto our production servers.It turned out this was the result of a chain of unexpected behaviors, the last one being how
uv
behaves when usinguv run
and howuv
handles signals.A quick summary of what I understand is happening:
When using
uv run
uv
will run Python as a subprocess and stick around until Python quits, or until it receives any of a whole bunch of signals:SIGKILL
(of course), but alsoSIGHUP
,SIGQUIT
,SIGILL
,SIGTRAP
,SIGABRT
, ...and for all of these
uv
simply quits, without passing the signal on to the underlying Python process, which leaves the Python process orphaned.When
uv
receivesSIGINT
it will swallow the first signal it receives (#12108), which there might be good reasons for, but is also unexpected.All of this has been brought up in issues here before.
The best way that I found to avoid any of these issues seems to be to not use
uv run
and instead haveuv
only create the environment and then use the venv yourself, likeThis seems like a complicated solution to me – the opposite of why I came to love
uv
. ;)As mentioned before, this has been discussed in multiple issues already, and there seems to be no consensus how
uv
should handle signals better.Why does
uv
have to keep running though? Ifuv
simply replaced its own process with the Python process (man 3 exec
), none of this would be an issue.The documentation says
which I'm not even sure about what that means.
Could we add a new option to
uv run
to in fact haveuv
do all its magic, and then quit when it spawns the Python process?Something like
Of course a better name than
--exec
could be found, maybe--no-subprocess
, or--cede-control
.Platform
Darwin 24.4.0 arm64
Version
uv 0.6.12 (Homebrew 2025-04-02)
Python version
Python 3.13.1
The text was updated successfully, but these errors were encountered: