Skip to content

fix(events): dispatch foreign loops through serving loop - #1603

Merged
debpalash merged 6 commits into
integrate/open-repairs-20260820from
fix/integration-eventbus-loop
Aug 20, 2026
Merged

fix(events): dispatch foreign loops through serving loop#1603
debpalash merged 6 commits into
integrate/open-repairs-20260820from
fix/integration-eventbus-loop

Conversation

@debpalash

Copy link
Copy Markdown
Owner

Summary

Tests

  • HF_HUB_OFFLINE=1 uv run --frozen pytest -q tests/test_event_bus_thread_emit.py
  • targeted watermark lifecycle, generation, route coverage, and changelog tests

Stacked on integration branch; do not merge independently to main.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR routes event broadcasts from foreign asyncio loops onto the WebSocket serving loop and centralizes asynchronous watermark dispatch with fail-open behavior during bounded shutdown.

  • Updates generation, batch, and archetype producers to use the shared asynchronous watermark helper.
  • Adjusts watermark executor lifecycle admission and adds regression coverage for cross-loop events and shutdown-time watermarking.
  • Corrects contributor attribution in the changelog.

Important Files Changed

Filename Overview
backend/core/event_bus.py Foreign-loop emitters now schedule broadcasts thread-safely on the loop that owns listener queues and synchronization state.
backend/services/watermark.py Adds a shared asynchronous watermark dispatcher that preserves successful audio when executor admission is closed during shutdown.
backend/services/model_manager.py Distinguishes a live executor from one already shutting down when reopening watermark submissions for a lifespan.
backend/api/routers/generation.py Replaces duplicated executor dispatch at finalization and streaming-preview sites with the shared watermark helper.
backend/api/routers/archetypes.py Migrates archetype watermarking to the shared helper while retaining its existing bounded dispatch.
backend/api/routers/batch.py Migrates whole-track batch watermarking to the shared dedicated-pool helper.
tests/test_event_bus_thread_emit.py Adds deterministic coverage proving a producer on a foreign running loop reaches a listener owned by the serving loop.
tests/test_watermark_prefetch_coldstart.py Extends bounded-shutdown coverage to verify asynchronous watermark dispatch returns completed audio unchanged while admission is closed.

Reviews (1): Last reviewed commit: "Merge remote-tracking branch 'contributo..." | Re-trigger Greptile

@debpalash
debpalash merged commit 0a07202 into integrate/open-repairs-20260820 Aug 20, 2026
2 checks passed
@debpalash
debpalash deleted the fix/integration-eventbus-loop branch August 20, 2026 04:02
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.

1 participant