TypeError: 'function' object is not iterable
Closed this issue · 2 comments
Hi,
The following code works fine before 1.11.0
@funcy.retry(5, lambda attempt: attempt * 2)
Now it's broken with the following exception
File "/Users/ykoasanto/Veracode/Agora/Laputa/agora-ecsinfra/ecsinfra/service/deploy_helpers.py", line 196, in poll_ecs_for_steady_state kankyo_name, service_name) File "/Users/ykoasanto/Veracode/venv/ecsinfra/lib/python2.7/site-packages/funcy/decorators.py", line 38, in wrapper return deco(call, *dargs, **dkwargs) File "/Users/ykoasanto/Veracode/venv/ecsinfra/lib/python2.7/site-packages/funcy/flow.py", line 93, in retry errors = _ensure_exceptable(errors) File "/Users/ykoasanto/Veracode/venv/ecsinfra/lib/python2.7/site-packages/funcy/flow.py", line 122, in _ensure_exceptable return errors if is_exception else tuple(errors) TypeError: 'function' object is not iterable
I think the removal of the check for a list type here have caused this issue:
The second argument is errors and this never worked. It failed later though:
In [1]: from funcy import retry, raiser
In [2]: f = retry(5, lambda x: 1)(lambda: 10)
In [3]: f()
Out[3]: 10
In [4]: f = retry(5, lambda x: 1)(raiser())
In [5]: f()
# ... long story short ...
TypeError: catching classes that do not inherit from BaseException is not allowed
You should name argument here:
@funcy.retry(5, timeout=lambda attempt: attempt * 2)
def func(...):
# ...