Skip to content

Commit

Permalink
Fix flushing race in new multi-recording SDK (#2125)
Browse files Browse the repository at this point in the history
* add minimal_options py example and use it in e2e suite (catches 2fast2log races(

* make sure to push goodbye last
  • Loading branch information
teh-cmc authored May 16, 2023
1 parent 9125cf5 commit 30e7d63
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/re_sdk/src/recording_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,16 @@ impl RecordingStream {
return;
};

// TODO(cmc): The `Goodbye` message is our last remaining message piece that is neither
// idempotent, stateless, nor order insensitive... so make sure to get all the pending
// tables into the pipe first.

// 1. Flush the batcher down the table channel
this.batcher.flush_blocking();

// 2. Drain all pending tables from the batcher's channel _before_ any other future command
this.cmds_tx.send(Command::PopPendingTables).ok();

this.cmds_tx
.send(Command::RecordMsg(LogMsg::Goodbye(
this.info.recording_id.clone(),
Expand Down
23 changes: 23 additions & 0 deletions examples/python/minimal_options/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3

"""Demonstrates the most barebone usage of the Rerun SDK, with standard options."""


import argparse

import numpy as np
import rerun as rr

parser = argparse.ArgumentParser(description="Logs rich data using the Rerun SDK.")
rr.script_add_args(parser)
args, unknown = parser.parse_known_args()
[__import__("logging").warning(f"unknown arg: {arg}") for arg in unknown]

rr.script_setup(args, "minimal_options")

positions = np.vstack([xyz.ravel() for xyz in np.mgrid[3 * [slice(-5, 5, 10j)]]]).T
colors = np.vstack([rgb.ravel() for rgb in np.mgrid[3 * [slice(0, 255, 10j)]]]).astype(np.uint8).T

rr.log_points("my_points", positions=positions, colors=colors)

rr.script_teardown(args)
2 changes: 2 additions & 0 deletions examples/python/minimal_options/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy
rerun-sdk
1 change: 1 addition & 0 deletions examples/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-r dicom/requirements.txt
-r dna/requirements.txt
-r minimal/requirements.txt
-r minimal_options/requirements.txt
-r mp_pose/requirements.txt
-r multiprocessing/requirements.txt
-r multithreading/requirements.txt
Expand Down
2 changes: 2 additions & 0 deletions scripts/run_python_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def main() -> None:
requirements = [
"examples/python/api_demo/requirements.txt",
"examples/python/car/requirements.txt",
"examples/python/minimal_options/requirements.txt",
"examples/python/multithreading/requirements.txt",
"examples/python/plots/requirements.txt",
"examples/python/text_logging/requirements.txt",
Expand All @@ -61,6 +62,7 @@ def main() -> None:
# Trivial examples that don't require weird dependencies, or downloading data
("examples/python/api_demo/main.py", ["--demo", "all"]),
("examples/python/car/main.py", []),
("examples/python/minimal_options/main.py", []),
("examples/python/multithreading/main.py", []),
("examples/python/plots/main.py", []),
("examples/python/text_logging/main.py", []),
Expand Down

0 comments on commit 30e7d63

Please sign in to comment.