Skip to content

Allow metadata on multiple devices in parallel for REST - #15128

Merged
AviaAv merged 6 commits into
realsenseai:developmentfrom
AviaAv:multi-device-metadata
Jun 4, 2026
Merged

AviaAv merged 6 commits into
realsenseai:developmentfrom
AviaAv:multi-device-metadata

Conversation

@AviaAv

@AviaAv AviaAv commented May 31, 2026

Copy link
Copy Markdown
Contributor
  • Replace single-broadcaster MetadataSocketServer with per-device threads keyed by device_id.
  • Move emit path from a per-broadcaster asyncio loop (run_until_complete) to run_coroutine_threadsafe on the FastAPI main loop — required so N broadcasters can emit concurrently without racing on a shared loop.
  • Wire up symmetric teardown: stop_stream calls stop_broadcast(device_id); stop_sensor calls it when the last sensor on a device stops.
  • Fixes: with two devices streaming, metadata overlays now show on both (previously only the last start_broadcast target had metadata).

@AviaAv AviaAv changed the title Allow metadata on multiple devices in parallel Allow metadata on multiple devices in parallel for REST May 31, 2026

@Nir-Az Nir-Az left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 rs-agentic bot — automated PR review

This review was auto-generated by the rs-agentic bot. It covers potential bugs, enhancements, and guideline compliance for the multi-device-metadata change.

Summary

The core approach (per-device daemon threads + run_coroutine_threadsafe onto the FastAPI main loop) is architecturally sound and fixes the root cause. Several correctness and robustness issues are flagged inline.

⚠️ Missing Test Coverage

There is no test exercising the primary fix: two (or more) devices streaming simultaneously and both receiving metadata overlays. A test like:

def test_multi_device_metadata_parallel():
    # start_broadcast for device_A and device_B
    # assert both threads are alive and emitting
    # stop_broadcast for each
    # assert both threads terminate cleanly

would prevent regressions and document the expected multi-device contract.

@AviaAv
AviaAv requested a review from Nir-Az June 1, 2026 09:39
@Nir-Az
Nir-Az requested review from remibettan and removed request for Nir-Az June 2, 2026 03:50

@remibettan remibettan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@AviaAv
AviaAv merged commit 6d68cca into realsenseai:development Jun 4, 2026
29 of 30 checks passed
@AviaAv
AviaAv deleted the multi-device-metadata branch June 7, 2026 07:40
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.

3 participants