Repository navigation
Conversation
shsms
force-pushed
the
stream-idle-timeout
branch
from
October 21, 2026 15:04
da79257 to
1604390
Compare
The retry count of GrpcStreamBroadcaster was never reset, so a retry limit counted every retry over the life of the stream. A long-running stream with a limit gave up after that many lost connections, even when it had recovered from each one. Reset the count when a message arrives, so a limit counts the retries since the last message. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
A server stream that stays open without sending blocked its consumers forever. Cancel such a call and retry it like a failed one. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Abandoned streams kept retrying forever, so abandoned broadcasters piled up calls during outages. Track the receivers handed out and stop once all are closed or dropped, also while stalled or retrying. Also end the receivers on any exit of the stream: an unexpected error left them waiting forever. Now they end, and receivers with events get a StreamFatalError. And let stop() pass on a cancellation of its caller, which it used to swallow. A receiver with events requested after the stream stopped now ends at once too. If no receiver with events existed before, it used to wait on a new event channel that was never closed. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Some clients reuse a cached broadcaster without checking is_running, so a stream stopped for lack of receivers would hand them a receiver that ends without data. Start a new run instead. Each run already closes only its own channels, so the old run winding down cannot end the new run's receivers. A stream that ended, gave up or failed by itself is not restarted. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
shsms
force-pushed
the
stream-idle-timeout
branch
from
November 3, 2026 10:30
1604390 to
cacddab
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a reporting API outage, forecast streams stayed dead until a restart: a stalled call was never noticed, and abandoned broadcasters kept retrying forever. This adds an idle timeout to
GrpcStreamBroadcaster, stops a broadcaster once every receiver it handed out is gone, and starts it again on the nextnew_receiver().Changes
idle_timeout(defaultNone, so off): a timer per message gap. A call that stalls is cancelled and goes throughretry_strategywith aStreamIdleTimeoutError.weakref.finalize. Releases from other threads are handed back to the loop. When the last receiver is closed or garbage-collected, the run is cancelled, also while it is stalled or retrying. Note the order innew_receiver(): it counts the receiver before subscribing, because a garbage collection during subscribing could otherwise stop the run under the new receiver._Run). After a stop for lack of receivers,new_receiver()starts a new run with its own channels and a fresh retry budget. An old run that is still winding down cannot end the new run's receivers. A stream that ended, gave up or failed by itself is not restarted, and nothing restarts afterstop().StreamFatalError.stop()passes on its caller's cancellation and waits for every run.Breaking
is_runningisFalseonce every receiver handed out is closed or garbage-collected, until the nextnew_receiver()starts the stream again.new_receiver()returns a wrapperReceiver:len()on it andMerger.stop()no longer work; useclose().