Skip to content

feat(py): add ergonomic route update iterator - #3229

Merged
kixelated merged 2 commits into
mainfrom
codex/python-route-watch-3193
Aug 31, 2026
Merged

feat(py): add ergonomic route update iterator#3229
kixelated merged 2 commits into
mainfrom
codex/python-route-watch-3193

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Closes #3193.

Summary

  • Add RouteWatch, an async iterator and async context manager for the current broadcast route and subsequent updates.
  • Keep route_changed() compatible by backing it with one cached watch cursor.
  • Fix dropped foreign async calls so they abort the exact detached Rust task. Previously, cancelling or timing out anext() could leave that task holding the watch state forever, causing the next call to hang.
  • Make explicit watch cancellation terminal even when it occurs before the first wait.

Public API changes

  • Add Python BroadcastConsumer.route_updates() -> RouteWatch.
  • Add Python RouteWatch with async iteration, async context management, and cancel().
  • Existing route_changed() behavior remains available.

The moq-ffi changes are internal task-lifecycle fixes; no generated FFI, C, Swift, Kotlin, or Go surface changes are required.

Test plan

  • nix develop --command just fix
  • nix develop --command just check
  • nix develop --command just test
  • 55 Python tests pass, including current value, ordered updates, clean end, context cleanup, pending cancellation, timeout reuse, and route_changed() compatibility.
  • 67 moq-ffi tests pass, including dropped-run state release and cancel-before-run terminal behavior.

(Written by GPT-5.6)

kixelated and others added 2 commits August 31, 2026 09:27
Co-Authored-By: GPT-5.6 <noreply@openai.com>
Co-Authored-By: GPT-5.6 <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 37 minutes.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8c368ad6-cfbf-4937-8239-f6faaa2c36e1

📥 Commits

Reviewing files that changed from the base of the PR and between a2e4421 and 6520134.

📒 Files selected for processing (7)
  • doc/lib/py/moq-rs.md
  • py/moq-rs/README.md
  • py/moq-rs/docs/index.md
  • py/moq-rs/moq/__init__.py
  • py/moq-rs/moq/subscribe.py
  • py/moq-rs/tests/test_local.py
  • rs/moq-ffi/src/ffi.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65201348cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"""Async iterator of a broadcast's route changes.

Created by :meth:`BroadcastConsumer.route_updates`. The first item is the
current route, followed by each update. Iteration ends when the broadcast

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not promise delivery of every route update

When a producer calls set_route more than once before the consumer requests its next item, this iterator does not yield each update as documented. poll_route_changed in rs/moq-net/src/model/broadcast.rs only compares the saved epoch with the current epoch and returns the single current state.route, so intermediate routes are overwritten. Either buffer route events or document this watch as latest-value/coalescing; otherwise consumers relying on a complete route history silently miss changes.

AGENTS.md reference: AGENTS.md:L117-L117

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T16:37:49.515090Z 6520134 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kixelated
kixelated merged commit 1798dc3 into main Aug 31, 2026
3 checks passed
@kixelated
kixelated deleted the codex/python-route-watch-3193 branch August 31, 2026 20:37
This was referenced Aug 31, 2026
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.

Expose a cancellable route watch API in Python

1 participant