def decorate(target): # change names because python 2.x doesn't have nonlocal logger_ = _prepare_logger(logger) on_success_ = _config_handlers(on_success) on_backoff_ = _config_handlers( on_backoff, _log_backoff, logger_, backoff_log_level ) on_giveup_ = _config_handlers( on_giveup, _log_giveup, logger_, giveup_log_level ) retry = None if sys.version_info >= (3, 5): # pragma: python=3.5 import asyncio if asyncio.iscoroutinefunction(target): import backoff._async retry = backoff._async.retry_predicate if retry is None: retry = _sync.retry_predicate return retry(target, wait_gen, predicate, max_tries, max_time, jitter, on_success_, on_backoff_, on_giveup_, wait_gen_kwargs)
def decorate(target): # change names because python 2.x doesn't have nonlocal logger_ = _prepare_logger(logger) on_success_ = _config_handlers(on_success) on_backoff_ = _config_handlers(on_backoff, _log_backoff, logger_, backoff_log_level) on_giveup_ = _config_handlers(on_giveup, _log_giveup, logger_, giveup_log_level) return retry_exception_itr(target, wait_gen, exception, max_tries, max_time, jitter, giveup, on_success_, on_backoff_, on_giveup_, wait_gen_kwargs)