I have the following third party decorator:
def retry(exception_to_check, tries=4, delay=3, backoff=2, logger=None):
I would like to make another decorator, @my_retry
, that is similar to @retry
, but with fixed arguments.
I've tried doing it using functools.partial
:
my_retry = partial(retry, RETRY_EXCEPTIONS, tries=5, delay=5, backoff=3, logger=logging)
But when I use the new decorator I get the following exception:
TypeError: retry() got multiple values for keyword argument 'tries'
What am I doing wrong?
What you need to do is to make a wrapper around retry
, like this
def my_retry(retry_exceptions, tries=5, delay=5, backoff=3, logger=logging):
return retry(retry_exceptions, tries, delay, backoff, logger)
and use @my_retry()
.