Skip to content

Send user code stderr to the exercise console - #307

Merged
javizqh merged 1 commit into
JdeRobot:humble-develfrom
Pranav-Singh-Devloper:fix-user-code-stderr
Nov 7, 2026
Merged

javizqh merged 1 commit into
JdeRobot:humble-develfrom
Pranav-Singh-Devloper:fix-user-code-stderr

Conversation

@Pranav-Singh-Devloper

Copy link
Copy Markdown
Contributor

Fixes #306

The user process was started with stderr=sys.stdout, which is RAM's own stdout (the container log). In Python exercises stderr only reaches the console after import WebGUI, because start_console() replaces sys.stderr there, so anything raised before that import was lost. With stderr=subprocess.STDOUT the process's stderr goes to the same console as its stdout. The C++ templates already reopen stderr on the console, so Python now behaves the same way.

Testing (Image Classification):

  • Wrong model file name before import WebGUI: the NoSuchFile traceback is now shown in the console (before: empty console).
  • Working code runs normally and the GUI works.
  • An exception raised after import WebGUI is shown once, not twice.
  • import onnxruntime, torch, cv2 and rclpy print nothing to stderr in the RADI, so this adds no noise.
  • black --check passes.

Please merge together with JdeRobot/RoboticsAcademy#4101. Without it, every run shows two Error sending message: socket is already closed. lines from gui_interfaces in the console.

Before

ram-stderr-before.mp4

After

ram-stderr-after.mp4

The user process was started with stderr=sys.stdout, i.e. RAM's own stdout. Python exercises only redirect sys.stderr to the console when WebGUI is imported, so tracebacks raised before that import never reached the user. Merge stderr into the console stdout instead.

Fixes JdeRobot#306
@Pranav-Singh-Devloper

Copy link
Copy Markdown
Contributor Author

The failing test check isn't caused by this change. All 21 failures are KeyError: 'scene' at manager.py:325 (cfg_dict["scene"]), because the test configs don't include a scene key. The same tests fail the same way on #305 (run). I can open a separate issue for the outdated tests if that's useful.

@javizqh
javizqh merged commit da587c4 into JdeRobot:humble-devel Nov 7, 2026
1 check failed
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.

Errors in user code raised before import WebGUI never reach the exercise console

2 participants