Repository navigation
Highlights
This is a big one! Native raise TryAgain with minimum backoff! RetryDetails filtering! Explicit block names for non-decorator retries! Lazy imports on Python 3.15! Bug fixes! Optimizations! Oh my!
Full changelog below!
Special thanks
This release would not be possible without my generous sponsors! Thank you to all of you making sustainable maintenance possible! If you would like to join them, go to https://github.com/sponsors/hynek and check out the sweet perks!
Above and beyond
Variomedia AG (@variomedia), Tidelift (@tidelift), Kraken Tech (@kraken-tech), Klaviyo (@klaviyo), Privacy Solutions GmbH (@privacy-solutions), FilePreviews (@filepreviews), TestMu AI Open Source Office (Formerly LambdaTest) (@LambdaTest-Inc), Todoist Inc (@todoist), Daniel Fortunov (@asqui), and Kevin P. Fleming (@kpfleming).
Maintenance sustainers
Buttondown (@buttondown), Christopher Dignam (@chdsbd), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Rivo Laks (@rivol), Mike Fiedler (@miketheman), Duncan Hill (@cricalix), Colin Marquardt (@cmarqu), August Trapper Bigelow (@atbigelow), Nick Libertini (@libertininick), Brian M. Dennis (@crossjam), Al Sweigart (@asweigart), Celebrity News AG (@celebritynewsag), Sławomir Ehlert (@slafs), Mostafa Khalil (@khadrawy), Filip Mularczyk (@mukiblejlok), Thomas Klinger (@thmsklngr), Andreas Poehlmann (@ap--), Carlton Gibson (@carltongibson), and Roboflow (@roboflow).
Full changelog
Removed
- Support for Python 3.10.
Deprecated
-
Raising
tenacity.TryAgainin code that stamina retries now emits aDeprecationWarning. It only ever worked because stamina uses Tenacity internally. Raisestamina.exceptions.TryAgaininstead.Generally speaking, we do not support "hybrid" usage of Tenacity features via stamina and will break such cases without warning in the future. #158
Added
-
stamina.exceptions.TryAgainthat you can raise to force a retry, whatever on says. If stamina runs out of attempts, it raises the exception that you raisedTryAgainfrom. Without one, your caller gets theTryAgain.Pass after to wait at least a number of seconds, a
datetime.timedelta, or until a timezone-awaredatetime.datetimebefore the next attempt. #158 -
stamina.instrumentation.set_process_details()that lets you change thestamina.instrumentation.RetryDetailsbefore stamina passes them to the retry hooks. For example, you can remove secrets from the arguments before they are logged.stamina.instrumentation.get_process_details()returns the current one. #160 -
stamina.retry_context(),stamina.RetryingCaller(), andstamina.AsyncRetryingCaller()now accept a keyword-only name for retry instrumentation, like Prometheus labels. The default remains<context block>. #165
Changed
-
The type hints of on now accept subclasses of
BaseException, backoff hooks are typed to receive aBaseException, andstamina.instrumentation.RetryDetails.caused_byis typed as aBaseException. This matches what stamina always did at runtime; we've only imposed our opinion via type hints which isn't always useful. If you annotated the argument of a backoff hook withException, your type checker now wantsBaseException. #155 -
If a backoff would end after timeout, stamina now gives up right away. Before, it waited past timeout and attempted once more. This also applies to custom backoffs from backoff hooks. #158
-
On Python 3.15 and later, stamina now uses lazy imports. #159
Fixed
- Context managers returned by
stamina.instrumentation.RetryHooks are now exited only once. #157
This release contains contributions from @hynek, and @Ycz007.