Repository navigation
Keep pool time limits when asynloop exits on connection error - #10892
Closed
Kavin-Nithil wants to merge 1 commit into
Closed
Kavin-Nithil wants to merge 1 commit into
Kavin-Nithil wants to merge 1 commit into
Conversation
…error When the event loop exits on a connection error, asynloop called hub.timer.clear() to drop stale periodic entries (e.g. the transport's maybe_restore_messages) that would otherwise fire against the broken connection and crash the loop again during reconnect (celery#10218). The hub timer is shared with the rest of the worker, though. Clearing it also dropped the soft/hard time limit timers of tasks still running in the pool. Those tasks survive the reconnect but their time limits are never registered again, so they could run forever. Record the timer entries present before asynloop registers its own (heartbeats, pool maintenance, transport callbacks), and on error cancel only the entries this loop added. Entries owned by others are left in place. Behaviour on graceful shutdown is unchanged. Tests now use a real kombu Timer and cover cancelling only the loop's entries, repeated reconnects, and keeping other entries on error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kavin-Nithil
deleted the
fix/asynloop-keep-pool-time-limits-on-reconnect
branch
October 18, 2026 18:07
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.
Note: Before submitting this pull request, please review our contributing
guidelines.
Description
#10218 made
asynloopcallhub.timer.clear()when the event loop exits on a connection error. The goal was to drop stale periodic entries (such as the transport'smaybe_restore_messages) that would otherwise fire against the broken connection and crash the loop again during reconnect.The hub timer is shared with the rest of the worker, though. Clearing it also removes the soft/hard time limit timers of tasks still running in the pool. Those tasks keep running across the reconnect, but their time limits are never registered again. A task that should have been killed by
time_limit/soft_time_limitcan then run forever after a broker connection drop.Fix
asynloopregisters its own (AMQP heartbeats, event dispatcher heartbeats,register_with_event_loopcallbacks).asynloopcall registers them again after reconnect.WorkerShutdown/WorkerTerminate) behaves as before: nothing is cancelled.try/except, so the original connection error is always re-raised.Tests
The
asynlooptimer tests now use a realkombu.asynchronous.timer.Timerinstead of mockingclear(), and cover:cancel()orhub.reset()failsRelated: #10218
🤖 Generated with Claude Code