This repository was archived by the owner on Aug 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 156
Support runtime configuration with optionally callable kwargs #12
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
|
||
|
|
||
| # Evaluate arg that can be either a fixed value or a callable. | ||
| def _maybe_call(f, *args, **kwargs): |
Contributor
There was a problem hiding this comment.
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
Member
Author
There was a problem hiding this comment.
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.
Contributor
|
👍 |
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
22b55df to
ce9d114
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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