Skip to content

Print per-stream status lines atomically - #151

Open
fedemengo wants to merge 1 commit into
labstreaminglayer:masterfrom
fedemengo:fix/atomic-status-lines
Open

fedemengo wants to merge 1 commit into
labstreaminglayer:masterfrom
fedemengo:fix/atomic-status-lines

Conversation

@fedemengo

Copy link
Copy Markdown

Each stream's recording thread prints its status with chained << on std::cout. The threads leave enter_streaming_phase() together, so their Started data collection lines are printed at the same instant and can interleave mid-line, e.g.:

Started data collection for stream race6.Started data collection for stream Started data collection for stream Started data collection for stream

Tools that parse LabRecorderCLI's stdout line by line (e.g. pylabrecorder) then miss a stream and time out, although the recording is running fine.

This routes the per-stream messages through a small mutex-guarded helper that writes each line in one piece.

Reproduction: record 8 streams at once with LabRecorderCLI. Without this change the output above shows up on the first attempt; with it, every line holds exactly one message.

Each stream's recording thread prints its status with chained `<<` on
std::cout. The threads leave enter_streaming_phase() together, so their
"Started data collection" lines are printed at the same instant and can
interleave mid-line, e.g.:

  Started data collection for stream Started data collection for stream AB..

Wrappers that parse stdout line by line (pylabrecorder) then miss a
stream and time out although the recording is running. Route the
per-stream messages through a mutex-guarded helper that writes each
line in one piece.
@mscheltienne

Copy link
Copy Markdown

@cboulay We caught that one on our system using pylabrecorder as a python wrapper around LabRecorder's CLI, it would be great if you could include it at least on main for me to keep pylabrecorder pointing to the official LabRecorder's repository 🙏

mscheltienne added a commit to fedemengo/pylabrecorder that referenced this pull request Nov 9, 2026
- Reset the recorder when no stream matches, so it can be started again.
- Replace the stdout-interleaving test, which asserted the upstream fix
  (labstreaminglayer/App-LabRecorder#151), with a test that starting a
  recording of 8 streams succeeds whether or not lines are torn.
- Release the test outlets in a finally block so a failure does not leak
  streams into tests recording every stream on the network.
- Skip the fake-CLI tests on Windows, where a shell script can't be executed.
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.

2 participants