Bug: Unable to interrupt Python script after starting SimulationApp

I have created the following MRE:

import time

from omni.isaac.kit import SimulationApp

simulation_app = SimulationApp({"headless": True})

print("Isaac Sim running")
time.sleep(60)
print("Done")

If I save this script as test.py and try to run it with ~/.local/share/ov/pkg/isaac_sim-2023.1.1/python.sh test.py, I get output similar to this (as expected):

[...]
[11.003s] app ready
2024-04-18 13:12:27 [11,857ms] [Warning] [omni.kit.imgui_renderer.plugin] _createExtendCursor: No windowing.
2024-04-18 13:12:27 [11,857ms] [Warning] [omni.kit.imgui_renderer.plugin] _createExtendCursor: No windowing.
2024-04-18 13:12:27 [11,941ms] [Warning] [omni.kit.hotkeys.core.registry] [Hotkey] duplicated action as SPACE (On Press) with omni.kit.widget.toolbar.omni.kit.widget.toolbar::toolbar::play!
2024-04-18 13:12:27 [11,941ms] [Warning] [omni.kit.hotkeys.core.registry] [Hotkey] Cannot register Global [omni.kit.widget.toolbar] omni.kit.widget.toolbar::toolbar::play.SPACE, error code: Duplicated action definition
[12.254s] RTX ready
[12.823s] Simulation App Startup Complete
Isaac Sim running

At this point the script is running normally, but I am unable to kill it using Ctrl+C (nothing happens). If I send SIGTERM to the process (by running sudo pkill -ef test.py --signal SIGTERM in a different terminal) it closes the TTY but the process keeps running:

[12.823s] Simulation App Startup Complete
Isaac Sim running
Terminated
$ pgrep -af test.py
32594 [...]/.local/share/ov/pkg/isaac_sim-2023.1.1/kit/python/bin/python3 test.py

I can tell Python never even receives the SIGTERM signal, because after the 60 seconds have passed it still continues printing:

[...]
[12.770s] Simulation App Startup Complete
Isaac Sim running
Terminated
$ pgrep -af test.py
32594 [...]/.local/share/ov/pkg/isaac_sim-2023.1.1/kit/python/bin/python3 test.py
$ Done
2024-04-18 13:12:01 [72,769ms] [Warning] [carb] [Plugin: omni.spectree.delegate.plugin] Module /home/omniverse-10/.local/share/ov/pkg/isaac_sim-2023.1.1/kit/exts/omni.usd_resolver/bin/libomni.spectree.delegate.plugin.so remained loaded after unload request
2024-04-18 13:12:01 [72,772ms] [Warning] [omni.stageupdate.plugin] Deprecated: direct use of IStageUpdate callbacks is deprecated. Use IStageUpdate::getStageUpdate instead.
[...]

The only way to actually kill it is to send SIGKILL (sudo pkill -ef test.py --signal SIGKILL), but this does not allow my script to clean up after itself.

I am running Ubuntu 22.04 with Isaac Sim 2023.1.1.

1 Like