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.

Change-Id: I2af3cf024f5391088d602102d9a8039a46415f73
Closes-Bug: #1635380
This commit is contained in:
Sharat Sharma 2016-11-16 20:32:40 +05:30
parent 9b39d7bc62
commit c8cb137eb1
2 changed files with 3 additions and 3 deletions

View File

@ -18,7 +18,7 @@ from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_log import log
from oslo_service import threadgroup
from retrying import retry
import tenacity
import tooz.coordination
from mistral import utils
@ -95,7 +95,7 @@ class ServiceCoordinator(object):
self._started = False
@retry(stop_max_attempt_number=5)
@tenacity.retry(stop=tenacity.stop_after_attempt(5))
def join_group(self, group_id):
if not self.is_active() or not group_id:
return

View File

@ -46,7 +46,7 @@ python-ironic-inspector-client>=1.5.0 # Apache-2.0
python-zaqarclient>=1.0.0 # Apache-2.0
PyYAML>=3.10.0 # MIT
requests>=2.10.0 # Apache-2.0
retrying!=1.3.0,>=1.2.3 # Apache-2.0
tenacity>=3.2.1 # Apache-2.0
setuptools!=24.0.0,>=16.0 # PSF/ZPL
six>=1.9.0 # MIT
SQLAlchemy<1.1.0,>=1.0.10 # MIT