Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Conversation

@bgreen-litl
Copy link
Member

This makes the max_tries kwarg on on_exception and on_predicate
optionally accept a callable to be evaluated at runtime rather
than a fixed value.

Similarly, wait_gen_kwargs also optionally accept callables to be
evaluated before passing into the wait_gen. This means that all
current kwargs on backoff.expo, backoff.fibo, backoff.constant now
accept callables, and also that all future and user-space wait
generators will as well.

This addresses #10

@coveralls
Copy link

coveralls commented Aug 3, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling c23d947 on bgreen-litl:callable-kwargs into 787f678 on litl:master.

@coveralls
Copy link

coveralls commented Aug 3, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 11909e3 on bgreen-litl:callable-kwargs into 787f678 on litl:master.

@coveralls
Copy link

coveralls commented Aug 3, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 4f72882 on bgreen-litl:callable-kwargs into 787f678 on litl:master.



# Evaluate arg that can be either a fixed value or a callable.
def _maybe_call(f, *args, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer to not rely on exceptions for processing and do something along the lines of http://stackoverflow.com/questions/624926/how-to-detect-whether-a-python-variable-is-a-function

Copy link
Member Author

@bgreen-litl bgreen-litl Aug 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression there wasn't a portable way to do it across 2.6 (we've got some 2.6 PRs so I'm trying to keep supporting this) 2.7 3.x but it looks like the callable built-in should work despite briefly going away in early 3.x. I added a fixup to use it.

@coveralls
Copy link

coveralls commented Aug 4, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 313d7cf on bgreen-litl:callable-kwargs into 787f678 on litl:master.

@coveralls
Copy link

coveralls commented Aug 4, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 22b55df on bgreen-litl:callable-kwargs into 787f678 on litl:master.

@kazeka
Copy link
Contributor

kazeka commented Aug 5, 2016

👍

This makes the max_tries kwarg on on_exception and on_predicate
optionally accept a callable to be evaluated at runtime rather
than a fixed value.

Similarly, wait_gen_kwargs also optionally accept callables to be
evaluated before passing into the wait_gen. This means that all
current kwargs on backoff.expo, backoff.fibo, backoff.constant now
accept callables, and also that all future and user-space wait
generators will as well.

This addresses litl#10
@coveralls
Copy link

coveralls commented Aug 8, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling ce9d114 on bgreen-litl:callable-kwargs into e105de7 on litl:master.

@bgreen-litl bgreen-litl merged commit 0127223 into litl:master Aug 8, 2016
@bgreen-litl bgreen-litl deleted the callable-kwargs branch August 8, 2016 17:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants