Problem
Python handles route changes differently from the other bindings. BroadcastConsumer.route_changed() lazily creates a route watch, caches it in a private field, and awaits its next value:
The watch handle is not public and has no deterministic cancellation path. A caller that abandons route observation must rely on garbage collection or broadcast shutdown to release the native watch.
Other wrappers expose explicit lifetime ownership:
Proposed direction
Expose a public Python route watch abstraction with deterministic cleanup, following the existing wrapper conventions. Suitable shapes include:
- an async iterator returned by
routes()
- an async context-managed
RouteWatch
- both, with
route_changed() retained only as a convenience over the owned watch
The owner should be able to cancel a pending wait and release the native resource without waiting for garbage collection.
Acceptance criteria
- Python callers can explicitly own and close a route watch.
- Abandoning iteration deterministically cancels the native watch.
- A pending route wait is cancellable by normal asyncio task cancellation.
- Tests cover early iterator exit and cancellation while waiting.
- Lifecycle documentation matches the Go, Swift, and Kotlin ownership contract.
(Written by GPT-5.6)
Problem
Python handles route changes differently from the other bindings.
BroadcastConsumer.route_changed()lazily creates a route watch, caches it in a private field, and awaits its next value:BroadcastConsumerroute handlingThe watch handle is not public and has no deterministic cancellation path. A caller that abandons route observation must rely on garbage collection or broadcast shutdown to release the native watch.
Other wrappers expose explicit lifetime ownership:
RouteWatch.Next(ctx)andCancelFlowthat cancels the watch infinally.Proposed direction
Expose a public Python route watch abstraction with deterministic cleanup, following the existing wrapper conventions. Suitable shapes include:
routes()RouteWatchroute_changed()retained only as a convenience over the owned watchThe owner should be able to cancel a pending wait and release the native resource without waiting for garbage collection.
Acceptance criteria
(Written by GPT-5.6)