You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keep the current dict-based to_details() (type-unsafe, inconsistent)
Only fix idle_for and leave the rest (incomplete solution)
Remove statistics entirely (loss of useful debugging info)
Additional Context
tenacity exposes retrying.statistics as a dict via threading.local(). backon should provide something similar but typed and consistent across all modes.
Problem
backon has two retry loops with separate state objects:
_FastStatein_retry/_fast.py): bare-bones__slots__dataclass withelapsed,outcome,tries. No.statisticsproperty.RetryStatein_state.py): full dataclass with.statisticsproperty returningstart_time,attempt_number,idle_for,elapsed.This means:
AttemptorRetryStateexposed to user code — theto_details()dict is the only interfaceidle_foris buggy in the slow path (see state.idle_for += state.elapsed accumulates total time, not idle time — statistic grows quadratically #33 — grows quadratically)Proposed Solution
.statisticsto_FastState— return a consistent dict matching the slow path formatRetryStatisticsdataclass — instead of a raw dict, expose a typed dataclass:RetryingandRetryingCaller— after a retry completes, users can inspectretrying.statisticsfor the last callidle_for(reference state.idle_for += state.elapsed accumulates total time, not idle time — statistic grows quadratically #33) as part of this changeAlternatives
to_details()(type-unsafe, inconsistent)Additional Context
tenacity exposes
retrying.statisticsas a dict viathreading.local(). backon should provide something similar but typed and consistent across all modes.