Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass sleep_fn from retry to Retrier #11

Closed
pohmelie opened this issue Jan 9, 2017 · 2 comments
Closed

Can't pass sleep_fn from retry to Retrier #11

pohmelie opened this issue Jan 9, 2017 · 2 comments

Comments

@pohmelie
Copy link

pohmelie commented Jan 9, 2017

>>> import riprova
>>> import time
>>> def my_sleep(*args, **kwargs): print("my sleep", args, kwargs); time.sleep(*args, **kwargs)
... 
>>> my_sleep(1)
my sleep (1,) {}
>>> def fail(): raise Exception
... 
>>> riprova.retry(backoff=riprova.ConstantBackoff(interval=2, retries=5), sleep_fn=my_sleep)(fail)()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    riprova.retry(backoff=riprova.ConstantBackoff(interval=2, retries=5), sleep_fn=my_sleep)(fail)()
  File "/home/poh/pro/py/riprova/riprova/retry.py", line 132, in wrapper
    return retry_runner(*args, **kw)
  File "/home/poh/pro/py/riprova/riprova/retrier.py", line 294, in run
    delay = self._get_delay()
  File "/home/poh/pro/py/riprova/riprova/retrier.py", line 246, in _get_delay
    self.error)
  File "<string>", line 2, in raise_from
riprova.exceptions.MaxRetriesExceeded: max retries exceeded
>>> 

The reason is identical names for keyword only arguments for decorator and wrapper:
https://github.com/h2non/riprova/blob/master/riprova/retry.py#L24
https://github.com/h2non/riprova/blob/master/riprova/retry.py#L120

@pohmelie
Copy link
Author

pohmelie commented Jan 9, 2017

Actually I discover this when trying to implement #4 so, it will not work for any keyword only argument for retry

@h2non
Copy link
Owner

h2non commented Jan 11, 2017

Fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants