def retry_on_excs(excs, retry_count=3, delay=5):
    """Retry decorator used to retry callables on for specific exceptions.

    :param excs: Exceptions tuple.
    :param retry_count: Retry count.
    :param delay: Delay in seconds between retries.
    :return: Wrapped function object.
    """

    def wrapper(f):
        @functools.wraps(f)
        def deco(*args, **kwargs):
            for i in range(0, retry_count):
                try:
                    return f(*args, **kwargs)
                except excs:
                    if logger:
                        logger.warning(
                            'HTTPError caught.Retrying ...'.format(f.__name__),
                            exc_info=True
                        )
                    time.sleep(delay)
            else:
                logger.error(
                    '{} failed after {} retries'.format(
                        f.__name__, retry_count)
                )
            return f(*args, **kwargs)

        return deco

    return wrapper
def retry_on_excs ( excs , retry_count = 3 , delay = 5 ) : def wrapper ( f ) : @ functools . wraps ( f ) def deco ( * args , ** kwargs ) : for i in range ( 0 , retry_count ) : try : return f ( * args , ** kwargs ) except excs : if logger : logger . warning ( 'HTTPError caught.Retrying ...' . format ( f . __name__ ) , exc_info = True ) time . sleep ( delay ) else : logger . error ( '{} failed after {} retries' . format ( f . __name__ , retry_count ) ) return f ( * args , ** kwargs ) return deco return wrapper
Retry decorator used to retry callables on for specific exceptions.

    :param excs: Exceptions tuple.
    :param retry_count: Retry count.
    :param delay: Delay in seconds between retries.
    :return: Wrapped function object.