How to use the tenacity.after_log function in tenacity

To help you get started, we’ve selected a few tenacity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tiangolo / full-stack-fastapi-postgresql / {{cookiecutter.project_slug}} / backend / app / app / celeryworker_pre_start.py View on Github external
    after=after_log(logger, logging.WARN),
)
def init():
    try:
        # Try to create session to check if DB is awake
        db_session.execute("SELECT 1")
    except Exception as e:
        logger.error(e)
        raise e
github tiangolo / full-stack-fastapi-postgresql / {{cookiecutter.project_slug}} / backend / app / app / backend_pre_start.py View on Github external
@retry(
    stop=stop_after_attempt(max_tries),
    wait=wait_fixed(wait_seconds),
    before=before_log(logger, logging.INFO),
    after=after_log(logger, logging.WARN),
)
def init():
    try:
        # Try to create session to check if DB is awake
        db_session.execute("SELECT 1")
    except Exception as e:
        logger.error(e)
        raise e
github openstack / networking-generic-switch / networking_generic_switch / devices / netmiko_devices / juniper.py View on Github external
            after=tenacity.after_log(LOG, logging.DEBUG),
            # Reraise exceptions if our final attempt fails.
            reraise=True,
            # Retry on certain failures.
            retry=(tenacity.retry_if_exception_type(BaseRetryable)),
            # Stop after the configured timeout.
            stop=tenacity.stop_after_delay(
                int(self.ngs_config['ngs_commit_timeout'])),
            # Wait for the configured interval between attempts.
            wait=tenacity.wait_fixed(
                int(self.ngs_config['ngs_commit_interval'])),
        )
        def commit():
            try:
                net_connect.commit()
            except ValueError as e:
                # Netmiko raises ValueError on commit failure, and appends the
github awslabs / aws-data-wrangler / awswrangler / pandas.py View on Github external
                    after=tenacity.after_log(logger, logging.INFO))
    def _write_csv_to_s3_retrying(fs: Any, path: str, buffer: bytes) -> None:
        with fs.open(path, "wb") as f:
            f.write(buffer)
github apache / airflow / airflow / gcp / hooks / base.py View on Github external
def decorator(fun: Callable):
            default_kwargs = {
                'wait': tenacity.wait_exponential(multiplier=1, max=100),
                'retry': retry_if_temporary_quota(),
                'before': tenacity.before_log(logger, logging.DEBUG),
                'after': tenacity.after_log(logger, logging.DEBUG),
            }
            default_kwargs.update(**kwargs)
            return tenacity.retry(
                *args, **default_kwargs
            )(fun)
        return decorator
github willianantunes / django-graphql-playground / django_graphql_playground / apps / pubsub / services / producer.py View on Github external
def _retry_send(self, function: Callable, attempt=10, *args, **kwargs):
        retry_configuration = tenacity.Retrying(
            stop=tenacity.stop_after_attempt(attempt),
            wait=tenacity.wait_fixed(3) + tenacity.wait_random(0, 2),
            after=tenacity.after_log(logger, logger.level) if logger else None,
            reraise=True,
        )
        return retry_configuration(function, *args, **kwargs)
github laughingman7743 / PyAthena / pyathena / util.py View on Github external
def retry_api_call(func, config, logger=None,
                   *args, **kwargs):
    retry = tenacity.Retrying(
        retry=retry_if_exception(
            lambda e: getattr(e, 'response', {}).get(
                'Error', {}).get('Code', None) in config.exceptions
            if e else False),
        stop=stop_after_attempt(config.attempt),
        wait=wait_exponential(multiplier=config.multiplier,
                              max=config.max_delay,
                              exp_base=config.exponential_base),
        after=after_log(logger, logger.level) if logger else None,
        reraise=True
    )
    return retry(func, *args, **kwargs)