Skip to content

Releases: hynek/stamina

24.3.0

27 Aug 14:53
24.3.0
ffc07c7
Compare
Choose a tag to compare

Highlights

Three changes, three highlights! stamina now allows you to test your retry logic, by limit the number of retries, you can specify a callable that decides whether you, indeed want to retry on a certain exception (think: different HTTP errors), and finally there's more info on the Attempt object.

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), FilePreviews (@filepreviews), Klaviyo (@klaviyo), Daniel Fortunov (@asqui), Kevin P. Fleming (@kpfleming), and Wim Jeantine-Glenn (@wimglenn).

Maintenance Sustainers

Adam Hill (@adamghill), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Moving Content AG (@moving-content), ProteinQure (@ProteinQure), Jesse Snyder (@jessesnyder), Rivo Laks (@rivol), The Westervelt Company (@westerveltco), Philippe Galvan (@PhilippeGalvan), Birk Jernström (@birkjernstrom), Chris Withers (@cjw296), Christopher Dignam (@chdsbd), Stefan Hagen (@sthagen), Sławomir Ehlert (@slafs), Mostafa Khalil (@khadrawy), Filip Mularczyk (@mukiblejlok), Mike Fiedler (@miketheman), Thomas Klinger (@thmsklngr), Duncan Hill (@cricalix), Colin Marquardt (@cmarqu), Andreas Poehlmann (@ap--), Pieter Swinkels (@swinkels), August Bigelow (@atbigelow), Carlton Gibson (@carltongibson), and Roboflow (@roboflow).

Not to forget 8 more amazing humans who chose to be generous but anonymous!

Full Changelog

Added

  • The on argument in all retry functions now can be a callable that takes an exception and returns a bool which decides whether or not a retry should be scheduled. #70

  • stamina.Attempt now has a next_wait attribute that contains the time the next backoff will wait, if the current attempt fails (sans jitter). #72

  • It is now possible to switch stamina into a testing mode using stamina.set_testing(). It disables backoffs and caps the number of retries. #73


This release contains contributions from @gsakkis, @hynek, and @wlach.

Artifact Attestations

You can verify this release's artifact attestions using GitHub's CLI tool by downloading the sdist and wheel from PyPI and running:

$ gh attestation verify --owner hynek stamina-24.3.0.tar.gz

and

$ gh attestation verify --owner hynek stamina-24.3.0-py3-none-any.whl

24.2.0

31 Jan 06:23
24.2.0
fa4769e
Compare
Choose a tag to compare

Highlights

This release adds two handy classes for the cases when you just want to retry a single function/method call:

def do_something_with_url(url, some_kw):
    resp = httpx.get(url)
    resp.raise_for_status()
    ...

rc = stamina.RetryingCaller(attempts=5)

rc(httpx.HTTPError, do_something_with_url, f"https://httpbin.org/status/404", some_kw=42)

# You can also create a caller with a pre-bound exception type:
bound_rc = rc.on(httpx.HTTPError)

bound_rc(do_something_with_url, f"https://httpbin.org/status/404", some_kw=42)

Both rc and bound_rc run:

do_something_with_url(f"https://httpbin.org/status/404", some_kw=42)

Unfortunately, it's not possible to implement this behavior transparently for async, so you have to use AsyncRetryingCaller for async callables.

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), FilePreviews (@filepreviews), Daniel Fortunov (@asqui), Kevin P. Fleming (@kpfleming), and Sören Weber (@SoerenWeber).

Maintenance Sustainers

Adam Hill (@adamghill), Dan Groshev (@si14), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Moving Content AG (@moving-content), ProteinQure (@ProteinQure), Jesse Snyder (@jessesnyder), Rivo Laks (@rivol), Ionel Cristian Mărieș (@ionelmc), The Westervelt Company (@westerveltco), Philippe Galvan (@PhilippeGalvan), Birk Jernström (@birkjernstrom), Tim Schilling (@tim-schilling), Chris Withers (@cjw296), Christopher Dignam (@chdsbd), Stefan Hagen (@sthagen), Sławomir Ehlert (@slafs), Mostafa Khalil (@khadrawy), Filip Mularczyk (@mukiblejlok), Mike Fiedler (@miketheman), and Michel Vittória (@michelvittoria).

Not to forget 5 more amazing humans who chose to be generous but anonymous!

Full Changelog

Added

  • stamina.RetryingCaller and stamina.AsyncRetryingCaller that allow even easier retries of single callables: stamina.RetryingCaller(attempts=5).on(ValueError)(do_something, "foo", bar=42) and stamina.RetryingCaller(attempts=5)(ValueError, do_something, "foo", bar=42) will call do_something("foo", bar=42) and retry on ValueError up to 5 times.

    stamina.RetryingCaller and stamina.AsyncRetryingCaller take the same arguments as stamina.retry(), except for on that can be bound separately.

    #56 #57

24.1.0

03 Jan 15:33
24.1.0
3b6d7bd
Compare
Choose a tag to compare

Highlights

This release only fixes one fun bug caused by one missing return statement. If you ever wondered why you successful blocks got retried when you deactivated stamina – wonder no longer.

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), FilePreviews (@filepreviews), Daniel Fortunov (@asqui), and Kevin P. Fleming (@kpfleming).

Maintenance Sustainers

Adam Hill (@adamghill), Dan Groshev (@si14), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Moving Content AG (@moving-content), ProteinQure (@ProteinQure), Jesse Snyder (@jessesnyder), Rivo Laks (@rivol), Ionel Cristian Mărieș (@ionelmc), The Westervelt Company (@westerveltco), Philippe Galvan (@PhilippeGalvan), Birk Jernström (@birkjernstrom), Tim Schilling (@tim-schilling), Chris Withers (@cjw296), Christopher Dignam (@chdsbd), Stefan Hagen (@sthagen), Sławomir Ehlert (@slafs), Mostafa Khalil (@khadrawy), Filip Mularczyk (@mukiblejlok), and Mike Fiedler (@miketheman).

Not to forget 6 more amazing humans who chose to be generous but anonymous!

Full Changelog

Fixed

  • stamina doesn't retry successful blocks when it's deactivated anymore (yes, you read it right). #54

23.3.0

05 Dec 14:24
23.3.0
79839ad
Compare
Choose a tag to compare

Highlights

Support for the Trio async framework!

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), FilePreviews (@filepreviews), Daniel Fortunov (@asqui), and Kevin P. Fleming (@kpfleming).

Maintenance Sustainers

Adam Hill (@adamghill), Dan Groshev (@si14), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Moving Content AG (@moving-content), ProteinQure (@ProteinQure), Jesse Snyder (@jessesnyder), Rivo Laks (@rivol), Ionel Cristian Mărieș (@ionelmc), The Westervelt Company (@westerveltco), Philippe Galvan (@PhilippeGalvan), Birk Jernström (@birkjernstrom), Tim Schilling (@tim-schilling), Chris Withers (@cjw296), Christopher Dignam (@chdsbd), Stefan Hagen (@sthagen), Sławomir Ehlert (@slafs), Mostafa Khalil (@khadrawy), and Filip Mularczyk (@mukiblejlok).

Not to forget 5 more amazing humans who chose to be generous but anonymous!

Full Changelog

Added

23.2.0

30 Oct 07:17
23.2.0
4203a17
Compare
Choose a tag to compare

Highlights

The highlight of this release are without question configurable retry hooks! You can now freely configure functions that are run whenever a retry is scheduled.

Can't wait to see what kind of third-party integrations y'all come up with – please show and tell us!

As a bonus, stamina now also comes with standard library's logging instrumentation out of the box.

If you have praise, comments, or concerns (that aren't outright bugs), head over to the release discussion!

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), HiredScore (@HiredScore), FilePreviews (@filepreviews), Daniel Fortunov (@asqui), and Kevin P. Fleming (@kpfleming).

Maintenance Sustainers

Adam Hill (@adamghill), Dan Groshev (@si14), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Moving Content AG (@moving-content), ProteinQure (@ProteinQure), Jesse Snyder (@jessesnyder), Rivo Laks (@rivol), Ionel Cristian Mărieș (@ionelmc), The Westervelt Company (@westerveltco), Philippe Galvan (@PhilippeGalvan), Birk Jernström (@birkjernstrom), Tim Schilling (@tim-schilling), Chris Withers (@cjw296), Christopher Dignam (@chdsbd), and Sławomir Ehlert (@slafs).

Not to forget 5 more amazing humans who chose to be generous but anonymous!

Full Changelog

Added

  • Instrumentation is now pluggable! You can define your own hooks that are run with retry details whenever a retry is scheduled. The documentation now has a whole chapter on instrumentation. #37

  • If structlog is not installed, the scheduled retry is now logged using the standard library logging module by default. #35

Changed

  • Tenacity's internal AttemptManager object is no longer exposed to the user. This was an oversight and never documented. stamina.retry_context() now yields instances of stamina.Attempt. #22

  • Initialization of instrumentation is now delayed. This means that if there's no retries, there's no startup overhead from importing structlog and prometheus-client. #34

  • Some key names in structlog log messages have been renamed to better reflect their meaning (sleptwaited_so_far, attemptretry_num, and errorcaused_by). You can rename them back using structlog's structlog.processors.EventRenamer. #35

23.1.0

04 Jul 09:18
23.1.0
415abda
Compare
Choose a tag to compare

Highlights

With this release, stamina graduates to becoming a "real" project. It now has proper documentation and a backwards-compatibility policy.

The other highlights are certainly transparent support for async and retrying of arbitrary code blocks!

Full changelog can be found 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), Sentry (@getsentry), HiredScore (@HiredScore), FilePreviews (@filepreviews), and Daniel Fortunov (@asqui).

Maintenance Sustainers

Adam Hill (@adamghill), Dan Groshev (@si14), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Moving Content AG (@moving-content), Stein Magnus Jodal (@jodal), ProteinQure (@ProteinQure), Jesse Snyder (@jessesnyder), Rivo Laks (@rivol), Tom Ballinger (@thomasballinger), Ionel Cristian Mărieș (@ionelmc), The Westervelt Company (@westerveltco), Philippe Galvan (@PhilippeGalvan), Birk Jernström (@birkjernstrom), Tim Schilling (@tim-schilling), Chris Withers (@cjw296), Christopher Dignam (@chdsbd), Stefan Hagen (@sthagen), and zorazen (@ZoraZen).

Not to forget 3 more amazing humans who chose to be generous but anonymous!

Full Changelog

Added

  • Official Python 3.12 support. #9
  • Async support. #10
  • Retries of arbitrary blocks using (async) for loops and context managers. #12
  • Proper documentation. #16
  • A backwards-compatibility policy.

Changed

  • The timeout, wait_initial, wait_max, and wait_jitter arguments can now also be of type datetime.timedelta.

22.2.0

06 Oct 15:40
22.2.0
e6ef74f
Compare
Choose a tag to compare

Instrumentation!

Added

  • Retries are now instrumented.
    If prometheus-client is installed, retries are counted using the Prometheus counter stamina_retries_total.
    If structlog is installed, they are logged using a structlog logger at warning level.
    These two instrumentations are independent from each other.

22.1.0

02 Oct 09:34
22.1.0
a12c40c
Compare
Choose a tag to compare

First release!