Fix call tracking for all acquisition methods#15
Merged
Conversation
Fixes call tracking bugs where try_acquire(), async_try_acquire(), and acquire() did not increment call_count when track_calls=True. Changes: - Move call tracking to internal helper methods (_try_consume_one_token_sync, _try_acquire_sync) for cleaner architecture - Remove duplicate tracking from async_acquire (was causing double-counting after rebase with v0.3.2) - Context managers now delegate tracking to underlying acquisition methods - All acquisition methods now consistently track calls Fixes #15
The _record_call() method was acquiring self.lock even though all callers already held the lock. Since self.lock is an RLock (reentrant), this did not cause deadlocks but was inefficient and architecturally unclear. Changes: - Remove lock acquisition from _record_call() - Update docstring to document that caller must hold lock - Add Args documentation for clarity All 148 tests still pass.
461e2ca to
2215b0e
Compare
Owner
Author
Rebase and Code Review CompleteThis PR has been rebased on current main (incorporating v0.3.2 and v0.3.3 changes) and reviewed. All 148 tests pass. Changes Made During Rebase
Commits
Test ResultsAll 148 tests pass:
Ready to MergeThis PR is now ready to:
|
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.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68d220efa95c832c97c9bd9d65c443b0
Note
Ensure all acquisition paths (sync/async acquire and try) increment tracked call counts with refactored internal tracking under a single lock.
track_calls=Trueforacquire(),try_acquire(),async_acquire(), andasync_try_acquire()._record_call()require the caller to holdself.lock._try_consume_one_token_sync,_try_acquire_sync); context managers now delegate to these.trymethods; preserved mixed sync/async behavior.__version__to0.3.4and updatedCHANGELOG.md.Written by Cursor Bugbot for commit 2215b0e. This will update automatically on new commits. Configure here.