Use retrying instead of our custom code
This pulls in retrying that handles the retry logic better than ours custom made one. Change-Id: Iedf00e245702add4cf122ed39732378de44eb3db
This commit is contained in:
parent
cfdf585f2a
commit
135a523a94
|
@ -1,7 +1,7 @@
|
|||
pbr>=0.6,!=0.7,<1.0
|
||||
stevedore>=0.14
|
||||
six>=1.7.0
|
||||
decorator
|
||||
kazoo==1.3.1
|
||||
pymemcache>=1.2
|
||||
msgpack-python
|
||||
retrying
|
||||
|
|
|
@ -17,13 +17,11 @@
|
|||
# under the License.
|
||||
|
||||
import collections
|
||||
import decorator
|
||||
import random
|
||||
import time
|
||||
|
||||
import itertools
|
||||
import msgpack
|
||||
import pymemcache.client
|
||||
import retrying
|
||||
import six
|
||||
|
||||
from tooz import coordination
|
||||
|
@ -34,15 +32,14 @@ class Retry(Exception):
|
|||
"""Exception raised if we need to retry."""
|
||||
|
||||
|
||||
@decorator.decorator
|
||||
def retry(f, *args, **kwargs):
|
||||
for try_number in itertools.chain(six.moves.range(10),
|
||||
itertools.repeat(10)):
|
||||
try:
|
||||
return f(*args, **kwargs)
|
||||
except Retry:
|
||||
pass
|
||||
time.sleep(random.randint(0, (2 ** try_number)) / 1000.0)
|
||||
def retry_if_retry_raised(exception):
|
||||
return isinstance(exception, Retry)
|
||||
|
||||
|
||||
def retry(f):
|
||||
return retrying.retry(
|
||||
retry_on_exception=retry_if_retry_raised,
|
||||
wait='exponential_sleep', wait_exponential_max=1)(f)
|
||||
|
||||
|
||||
class MemcachedLock(locking.Lock):
|
||||
|
|
Loading…
Reference in New Issue