def call(f, exceptions=AssertionError, tries=STOP_MAX_ATTEMPT_NUMBER_DEFAULT):
"""Call a given function and treat it as eventually consistent.
The function will be called immediately and retried with exponential
backoff up to the listed amount of times.
By default, it only retries on AssertionErrors, but can be told to retry
on other errors.
For example:
@eventually_consistent.call
def _():
results = client.query().fetch(10)
assert len(results) == 10
"""
__tracebackhide__ = True
return retry(
wait_exponential_multiplier=WAIT_EXPONENTIAL_MULTIPLIER,
wait_exponential_max=WAIT_EXPONENTIAL_MAX_DEFAULT,
stop_max_attempt_number=tries,
retry_on_exception=_retry_on_exception(exceptions))(f)()
eventually_consistent.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录