Replace usage of 'retrying' with 'tenacity'
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ceilometer |
Fix Released
|
Wishlist
|
Julien Danjou |
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 ceilometer: | |
importance: | Undecided → Wishlist |
status: | New → Triaged |
Changed in ceilometer: | |
assignee: | nobody → gordon chung (chungg) |
Changed in ceilometer: | |
status: | Triaged → In Progress |
Changed in ceilometer: | |
assignee: | gordon chung (chungg) → Julien Danjou (jdanjou) |
Reviewed: https:/ /review. openstack. org/398641 /git.openstack. org/cgit/ openstack/ ceilometer/ commit/ ?id=380bb26dbb8 aec89ea853d8afd 435c213fd72b0c
Committed: https:/
Submitter: Jenkins
Branch: master
commit 380bb26dbb8aec8 9ea853d8afd435c 213fd72b0c
Author: gord chung <email address hidden>
Date: Wed Nov 16 23:25:09 2016 +0000
Replace retrying with tenacity
We are replacing all usages of the 'retrying' package with
'tenacity' as the author of retrying is not actively maintaining
the project. Tenacity is a fork of retrying, but has improved the
interface and extensibility (see [1] for more details). Our end
goal here is removing the retrying package from our requirements.
Tenacity provides the same functionality as retrying, but has the
following major differences to account for:
- 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.
This patch updates all usages of retrying with tenacity.
Unit tests will be added where applicable.
Note: This change is not newton critical so projects are welcome
to hold off on committing until post-newton. Ideally this change
will merge by the first part of Ocata so dependant functionality
can land and have time to solidify for Ocata.
[1] https:/ /github. com/jd/ tenacity
Closes-Bug: #1635394 626708369371167 184a40e6368
Change-Id: I0ad7deee3f17f6