Skip to content

Comments

Catch keyboard interrupt in rerun-sdk CLI and return exit codes#12496

Merged
rerun-sync[bot] merged 3 commits intomainfrom
michael/catch-keyboardinterrupt
Jan 23, 2026
Merged

Catch keyboard interrupt in rerun-sdk CLI and return exit codes#12496
rerun-sync[bot] merged 3 commits intomainfrom
michael/catch-keyboardinterrupt

Conversation

@MichaelGrupp
Copy link
Member

Fixes two issues:

  • Exit codes of the main() function weren't returned to the OS by the executable.
  • uncaught KeyboardInterrupt
    • if you installed rerun-sdk and terminate rerun with ctrl+c, there was an ugly traceback
    • we can catch it and return 130, which is the standard POSIX code for SIGINT termination
[2026-01-16T16:11:55Z INFO  rerun::commands::entrypoint] Caught Ctrl-C, quitting Rerun Viewer…
[2026-01-16T16:11:55Z DEBUG eframe::native::epi_integration] Closing root viewport (ViewportCommand::CancelClose was not sent)
[2026-01-16T16:11:55Z DEBUG eframe::native::run] Asking to exit event loop…
[2026-01-16T16:11:55Z DEBUG eframe::native::run] Received Event::LoopExiting - saving app state…
[2026-01-16T16:11:55Z DEBUG eframe::native::run] eframe window closed
Traceback (most recent call last):
  File "/Users/michael/code/rerun/rerun_py/rerun_sdk/rerun/__main__.py", line 25, in <module>
    main()
  File "/Users/michael/code/rerun/rerun_py/rerun_sdk/rerun/__main__.py", line 21, in main
    return cli_main()
           ^^^^^^^^^^
  File "/Users/michael/code/rerun/rerun_py/rerun_sdk/rerun_cli/__main__.py", line 35, in main
    return subprocess.call([target_path, *sys.argv[1:]])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/michael/code/rerun/.pixi/envs/default/lib/python3.11/subprocess.py", line 391, in call
    return p.wait(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/michael/code/rerun/.pixi/envs/default/lib/python3.11/subprocess.py", line 1264, in wait
    return self._wait(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/michael/code/rerun/.pixi/envs/default/lib/python3.11/subprocess.py", line 2053, in _wait
    (pid, sts) = self._try_wait(0)
                 ^^^^^^^^^^^^^^^^^
  File "/Users/michael/code/rerun/.pixi/envs/default/lib/python3.11/subprocess.py", line 2011, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

..now:

2026-01-16T16:22:03Z INFO  rerun::commands::entrypoint] Caught Ctrl-C, quitting Rerun Viewer…
[2026-01-16T16:22:03Z DEBUG eframe::native::epi_integration] Closing root viewport (ViewportCommand::CancelClose was not sent)
[2026-01-16T16:22:03Z DEBUG eframe::native::run] Asking to exit event loop…
[2026-01-16T16:22:03Z DEBUG eframe::native::run] Received Event::LoopExiting - saving app state…
[2026-01-16T16:22:03Z DEBUG eframe::native::run] eframe window closed
echo $?

130

@MichaelGrupp MichaelGrupp added 🪳 bug Something isn't working sdk-python Python logging API include in changelog CLI Related to the Rerun CLI labels Jan 16, 2026
Copy link
Member

@abey79 abey79 left a comment

Choose a reason for hiding this comment

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

nice

@MichaelGrupp
Copy link
Member Author

e2e test fails, probably because exit codes are now not lost anymore...?

@grtlr
Copy link
Member

grtlr commented Jan 23, 2026

What's the status of this PR?

@MichaelGrupp
Copy link
Member Author

Blocked by a side-effect, discovering that e2e test is broken. See https://rerunio.slack.com/archives/C045J1Z7DU7/p1768582805102949?thread_ts=1768581103.390639&cid=C045J1Z7DU7

@MichaelGrupp MichaelGrupp force-pushed the michael/catch-keyboardinterrupt branch from bd321e1 to 9d7d9e1 Compare January 23, 2026 11:51
@github-actions
Copy link

github-actions bot commented Jan 23, 2026

Web viewer built successfully.

Result Commit Link Manifest
9d7d9e1 https://rerun.io/viewer/pr/12496 +nightly +main

View image diff on kitdiff.

Note: This comment is updated whenever you push a commit.

re_log::info!(
"Timed out after successfully receiving {num_messages} messages. Assuming the client disconnected cleanly.",
);
return Ok(db);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the workaround for the test. The rest of the diff is due to a "unnecessary match statement" clippy lint.

Copy link
Member Author

Choose a reason for hiding this comment

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

note: this function is only for the e2e test, see comment above

@MichaelGrupp
Copy link
Member Author

@rerun-bot reality-sync

@rerun-sync
Copy link
Contributor

rerun-sync bot commented Jan 23, 2026

Sync complete. Mirror PR in reality: https://github.com/rerun-io/reality/pull/209

Triggered by @MichaelGrupp

Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Nice one!

@rerun-sync rerun-sync bot merged commit daeb576 into main Jan 23, 2026
47 checks passed
@rerun-sync rerun-sync bot deleted the michael/catch-keyboardinterrupt branch January 23, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪳 bug Something isn't working CLI Related to the Rerun CLI include in changelog sdk-python Python logging API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants