Skip to content

Ctrl-C to to uv run is not handled by the child process #5257

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

Closed
bluss opened this issue Jul 21, 2024 · 1 comment · Fixed by #5395
Closed

Ctrl-C to to uv run is not handled by the child process #5257

bluss opened this issue Jul 21, 2024 · 1 comment · Fixed by #5395
Labels
bug Something isn't working

Comments

@bluss
Copy link
Contributor

bluss commented Jul 21, 2024

uv 0.2.27
platform: linux (x86_64)

Jupyterlab wants to handle Ctrl-C but it doesn't get a chance to do it when started from uv run.

Steps to reproduce

  1. uv init jptest
  2. cd jptest
  3. uv run --with jupyterlab jupyter-lab
  4. Wait 3 seconds
  5. Ctrl-C

Jupyterlab prints something like this

Shut down this Jupyter server (y/[n])? [W 2024-07-21 15:57:14.911 LabApp] Could not determine jupyterlab build status without nodejs
[I 2024-07-21 15:57:19.915 ServerApp] No answer for 5s:
[I 2024-07-21 15:57:19.915 ServerApp] resuming operation...

No input reaches jupyterlab after the Ctrl-C, so it doesn't get an answer to its y/[n] question.

Depending on circumstances jupyterlab is either continuing to run or shutting down in the background. uv run seems to terminate itself and leave its child process running.

Both jupyterlab and uv run receive the signal? In the Expected behaviour, jupyterlab should handle this signal alone (and it does so using the prompt in the output)?

I think a good solution to this would also solve the ipykernel launch problem mentioned in #3095.

rye run handles this one as expected. pdm run doesn't let jupyter-lab handle the signal but at least jupyter-lab is not left running detached.

Wish would be that it works the same way as if the user is running .venv/bin/jupyter-lab, if that's possible.

@bluss bluss changed the title Ctrl-C to to uv run is not reaching the process Ctrl-C to to uv run is not handled by the child process Jul 21, 2024
@bluss
Copy link
Contributor Author

bluss commented Jul 21, 2024

Also worth experimenting with just the Python REPL the same way. Less dependencies, similar problem.

Compare how this one handles Ctrl-C:

uv run python

compared with:

python

@zanieb zanieb added the bug Something isn't working label Jul 21, 2024
charliermarsh added a commit that referenced this issue Jul 24, 2024
## Summary

This is a bit simpler than #5333, but seems to work in my testing on
macOS and Windows. It's based on implementations that I found in
[Pixi](https://github.com/prefix-dev/pixi/blob/36f1bb297db04337172510f41e5b03d7da13c49f/src/cli/exec.rs#L99)
and
[Wasmer](https://github.com/wasmerio/wasmer/blob/49e60af8df31015cadee063c0e4618b81573fec2/lib/wasix/src/state/builder.rs#L1058).

Closes #5257.

## Test Plan

On both macOS and Windows:

- `cargo run -- tool run --from jupyterlab jupyter-lab` -- hit Ctrl-C;
verify that the process exits and the terminal is left in a good state.
- `cargo run -- run python` -- hit Ctrl-C; verify that the process does
_not_ exit, but does on Ctrl-D.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Done
2 participants