fix: set rpm controller timer as daemon to prevent process hang #4001
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.
Currently if you specify a
max_rpmto an Agent, the program is unable to exit. To the user this looks like a program that never exits even after completion.I think this is due to the Timer thread used to monitor the rate limiter inheriting Daemon behaviour from caller.
Proposed fix essentially says we always want to kill this specific timer if we exit no matter what and we make no effort to gracefully stop the timer. This solution seems reasonable for a timer that is simply a helper on rate limiting to external providers. No critical code (by definition) should be running while this thread is waiting.
Small reproducible example on my system, adapted from the docs:
On my system before the change this code hangs and never exits (after print result); after the change it works as expected.
Note
Marks the RPMController's reset timer as a daemon thread so processes can exit cleanly when max_rpm is set.
Written by Cursor Bugbot for commit 26a0597. This will update automatically on new commits. Configure here.