Replace usage of 'retrying' with 'tenacity'
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
os-brick |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
Today a number of OpenStack projects use the 'retrying' library [1] for generic retry behavior. While retrying provides a functional API, its author no longer actively maintains the repo and hasn't responded to numerous PRs, emails, etc. (more discussion in [2]). As a result, we can't push fixes/features to retrying to support various initiatives such as [3].
A fellow stacker graciously forked the retrying repo and revamped it's API to provide greater functionality/
- Tenacity uses seconds rather than ms as retrying did.
- Tenacity has different kwargs for the decorator and
Retrying class itself.
- Tenacity has a different approach for retrying args by
using classes for its stop/wait/retry kwargs.
- By default tenacity raises a RetryError if a retried callable
times out; retrying raises the last exception from the callable.
Tenacity provides backwards compatibility here by offering
the 'reraise' kwarg.
- Tenacity defines 'time.sleep' as a default value for a kwarg.
That said consumers who need to mock patch time.sleep
need to account for this via mocking of time.sleep before
tenacity is imported.
- For retries that check a result, tenacity will raise if the retried
function raises, whereas retrying retried on all exceptions.
We'd like to move from retrying to tenacity and eventually remove retrying from global requirements all together.
For projects using retrying, the move to tenacity (hopefully) isn't overly intrusive, but must take the above differences into consideration.
While I'm working to move all affected projects [6] from retrying to tenacity, this effort is a work in progress (under [5]).
[1] https:/
[2] https:/
[3] http://
[4] https:/
[5] https:/
[6] http://
Changed in os-brick: | |
importance: | Undecided → Wishlist |
Reviewed: https:/ /review. opendev. org/725741 /git.openstack. org/cgit/ openstack/ os-brick/ commit/ ?id=3f1314674d5 9bca6e9d0e43d4d 479bb04f20aca1
Committed: https:/
Submitter: Zuul
Branch: master
commit 3f1314674d59bca 6e9d0e43d4d479b b04f20aca1
Author: Sean McGinnis <email address hidden>
Date: Tue May 5 19:52:12 2020 -0500
Switch from retrying to tenacity
This switching our retry mechanism over from the retrying library to the
tenacity library. Retrying has been active for a few years now and
appears to be no longer maintained.
This has a small behavior change in that before we were applying an
exponential backoff to the first time a retry was needed. This no longer
happens, but retries will exponentially back off with each retry.
Also cleaned up some minor nits with unit test assert argument order.
Closes-bug: #1635397
Change-Id: I24cab206b16e63 859d4886c55d40a 03d398ce30d
Signed-off-by: Sean McGinnis <email address hidden>