Replaced bundled code with using six
This commit is contained in:
parent
30b068f26a
commit
062c5ba16b
|
@ -0,0 +1 @@
|
|||
six
|
28
retrying.py
28
retrying.py
|
@ -36,35 +36,11 @@
|
|||
## ----------------------------------------------------------------------------
|
||||
|
||||
import random
|
||||
import six
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
# Python 3 compatibility hacks, pilfered from https://pypi.python.org/pypi/six/1.6.1
|
||||
PY3 = sys.version_info[0] == 3
|
||||
if PY3:
|
||||
def reraise(tp, value, tb=None):
|
||||
if value.__traceback__ is not tb:
|
||||
raise value.with_traceback(tb)
|
||||
raise value
|
||||
|
||||
else:
|
||||
def exec_(_code_, _globs_=None, _locs_=None):
|
||||
"""Execute code in a namespace."""
|
||||
if _globs_ is None:
|
||||
frame = sys._getframe(1)
|
||||
_globs_ = frame.f_globals
|
||||
if _locs_ is None:
|
||||
_locs_ = frame.f_locals
|
||||
del frame
|
||||
elif _locs_ is None:
|
||||
_locs_ = _globs_
|
||||
exec("""exec _code_ in _globs_, _locs_""")
|
||||
|
||||
|
||||
exec_("""def reraise(tp, value, tb=None):
|
||||
raise tp, value, tb
|
||||
""")
|
||||
|
||||
# sys.maxint / 2, since Python 3.2 doesn't have a sys.maxint...
|
||||
MAX_WAIT = 1073741823
|
||||
|
@ -282,7 +258,7 @@ class Attempt(object):
|
|||
if wrap_exception:
|
||||
raise RetryError(self)
|
||||
else:
|
||||
reraise(self.value[0], self.value[1], self.value[2])
|
||||
six.reraise(self.value[0], self.value[1], self.value[2])
|
||||
else:
|
||||
return self.value
|
||||
|
||||
|
|
4
setup.py
4
setup.py
|
@ -35,6 +35,9 @@ with open('README.rst') as file_readme:
|
|||
with open('HISTORY.rst') as file_history:
|
||||
history = file_history.read()
|
||||
|
||||
with open('requirements.txt') as file_requirements:
|
||||
requirements = file_requirements.read().splitlines()
|
||||
|
||||
settings.update(
|
||||
name='retrying',
|
||||
version='1.2.4-dev',
|
||||
|
@ -47,6 +50,7 @@ settings.update(
|
|||
keywords="decorator decorators retry retrying exception exponential backoff",
|
||||
py_modules= ['retrying'],
|
||||
test_suite="test_retrying",
|
||||
install_requires=requirements,
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue