Skip to content

Isolate retry statistics across concurrent calls - #702

Open
gyanu2507 wants to merge 1 commit into
jd:mainfrom
gyanu2507:fix/retry-stats-concurrency
Open

Isolate retry statistics across concurrent calls#702
gyanu2507 wants to merge 1 commit into
jd:mainfrom
gyanu2507:fix/retry-stats-concurrency

Conversation

@gyanu2507

Copy link
Copy Markdown

BaseRetrying.wraps() reused wrapped_f.statistics for every call so #519 stayed visible through functools.wraps. That same dict was cleared at the start of each invocation, so two threads (or a reentrant call) could wipe each other's attempt_number.

Each call now gets its own live dict. When the call finishes, the result is copied back onto the wrapper attribute so outer decorators still see the latest stats.

Fixes #701

wraps() was reusing wrapped_f.statistics for every invocation so concurrent or reentrant calls cleared and mutated one dict. Keep a per-call dict during the run, then copy the result back onto the wrapper so functools.wraps still sees the latest stats.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wraps(): concurrent or reentrant calls share and clear one statistics dict, violating thread-local contract

1 participant