From f717e1e4e6cd8dbc787d2b8260a6635dda23dc16 Mon Sep 17 00:00:00 2001 From: Hoang Bui <47828508+bongbui321@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:05:15 -0400 Subject: [PATCH] tools/rerun: streaming to one Viewer from multiple processes (#32595) * one spawn only * one blueprint * comment --- tools/rerun/run.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/rerun/run.py b/tools/rerun/run.py index 8a002f68babda0..1c3c0a59e3550b 100755 --- a/tools/rerun/run.py +++ b/tools/rerun/run.py @@ -39,6 +39,7 @@ def log_msg(msg, parent_key=''): pass # Not a plottable value def createBlueprint(): + blueprint = None timeSeriesViews = [] for topic in sorted(SERVICE_LIST.keys()): timeSeriesViews.append(rrb.TimeSeriesView(name=topic, origin=f"/{topic}/", visible=False)) @@ -51,9 +52,12 @@ def log_thumbnail(thumbnailMsg): bytesImgData = thumbnailMsg.get('thumbnail') rr.log("/thumbnail", rr.ImageEncoded(contents=bytesImgData)) -def process(blueprint, lr): +@rr.shutdown_at_exit +def process(lr): + rr.init("rerun_test") + rr.connect() + ret = [] - rr.init("rerun_test", spawn=True, default_blueprint=blueprint) for msg in lr: ret.append(msg) rr.set_time_nanos("TIMELINE", msg.logMonoTime) @@ -75,8 +79,11 @@ def process(blueprint, lr): args = parser.parse_args() - route_or_segment_name = DEMO_ROUTE if args.demo else args.route_or_segment_name.strip() blueprint = createBlueprint() + rr.init("rerun_test", default_blueprint=blueprint) + rr.spawn(connect=False) # child processes stream data to Viewer + + route_or_segment_name = DEMO_ROUTE if args.demo else args.route_or_segment_name.strip() print("Getting route log paths") lr = LogReader(route_or_segment_name) - lr.run_across_segments(NUM_CPUS, partial(process, blueprint)) + lr.run_across_segments(NUM_CPUS, partial(process))