def retry(retries=MYSQL_WAIT_RETRIES, delay=MYSQL_WAIT_INTERVAL,<EOL>check_exceptions=()):
def decorator(func):<EOL><INDENT>"""<STR_LIT>"""<EOL>def f_retry(*args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>for i in range(<NUM_LIT:1>, retries + <NUM_LIT:1>):<EOL><INDENT>try:<EOL><INDENT>return func(*args, **kwargs)<EOL><DEDENT>except check_exceptions + (Exception,) as exc:<EOL><INDENT>if i < retries:<EOL><INDENT>logger.info('<STR_LIT>',<EOL>i, retries)<EOL>if isinstance(exc, check_exceptions):<EOL><INDENT>logger.debug('<STR_LIT>',<EOL>exc_info=True)<EOL><DEDENT>else:<EOL><INDENT>logger.warn(<EOL>'<STR_LIT>',<EOL>exc_info=True)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logger.exception('<STR_LIT>', retries)<EOL>raise<EOL><DEDENT><DEDENT>time.sleep(delay)<EOL><DEDENT><DEDENT>return f_retry<EOL><DEDENT>return decorator<EOL>
Retry decorator.