Skip to content

Send user code stderr to the exercise console - #307

Open
Pranav-Singh-Devloper wants to merge 1 commit into
JdeRobot:humble-develfrom
Pranav-Singh-Devloper:fix-user-code-stderr
Open

Pranav-Singh-Devloper wants to merge 1 commit into
JdeRobot:humble-develfrom
Pranav-Singh-Devloper:fix-user-code-stderr

Conversation

@Pranav-Singh-Devloper

Copy link
Copy Markdown

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

This branch has not been deployed

No deployments
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

1 participant