Skip to content

fix: open tree_state in binary mode to fix resume on DL exercises - #297

Open
SomeshG1151 wants to merge 1 commit into
JdeRobot:humble-develfrom
SomeshG1151:fix/file-watchdog-binary-resume
Open

fix: open tree_state in binary mode to fix resume on DL exercises#297
SomeshG1151 wants to merge 1 commit into
JdeRobot:humble-develfrom
SomeshG1151:fix/file-watchdog-binary-resume

Conversation

@SomeshG1151

Copy link
Copy Markdown

Problem

Handler.on_modified in libs/file_watchdog.py opened the watched file
in text mode ("r"). DL exercises write binary data to /tmp/tree_state,
causing a UnicodeDecodeError that silently crashes the watchdog's event
thread. Once crashed, no further update_callback calls fire, so the
frontend never receives state updates and Resume appears permanently broken.

Fix

  • Read in binary mode ("rb")
  • Guard against transient OSError (e.g. file deleted between event and read)
  • Decode with errors="replace" so downstream consumers still receive str
  • Create blank sentinel file in binary mode for consistency

Related

Fixes JdeRobot/RoboticsAcademy#3926

Handler.on_modified opened the watched file in text mode ('r'), causing
UnicodeDecodeError on binary DL exercise state files. The exception
crashed the watchdog's event thread silently, preventing any further
update_callback calls and breaking Resume for the rest of the session.

Fix: read in binary mode ('rb'), guard against transient OSError,
decode with errors='replace' so downstream consumers still receive str.
Also create the blank sentinel file in binary mode for consistency.

Fixes: JdeRobot/RoboticsAcademy#3926
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.

Resume does not work properly on DL exercises

1 participant