Ensure we wrap the decorated functions

To avoid losing the original functions docs, name
and other attributes ensure that this correctly uses
six.wraps (which uses functools.wraps internally) to
wrap the decorated function.
This commit is contained in:
Joshua Harlow 2014-10-03 20:02:20 -07:00
parent cab083eb57
commit ee2ae2a9d3
1 changed files with 4 additions and 0 deletions

View File

@ -55,6 +55,8 @@ def retry(*dargs, **dkw):
# support both @retry and @retry() as valid syntax
if len(dargs) == 1 and callable(dargs[0]):
def wrap_simple(f):
@six.wraps(f)
def wrapped_f(*args, **kw):
return Retrying().call(f, *args, **kw)
@ -64,6 +66,8 @@ def retry(*dargs, **dkw):
else:
def wrap(f):
@six.wraps(f)
def wrapped_f(*args, **kw):
return Retrying(*dargs, **dkw).call(f, *args, **kw)