def retrySQL(timeoutSec=(60 * 5), logger=None):
 if (logger is None):
  logger = logging.getLogger(__name__)
 def retryFilter(e, args, kwargs):
  if isinstance(e, (pymysql.InternalError, pymysql.OperationalError)):
   if (e.args and (e.args[0] in _ALL_RETRIABLE_ERROR_CODES)):
    return True
  elif isinstance(e, pymysql.Error):
   if (e.args and inspect.isclass(e.args[0]) and issubclass(e.args[0], socket_error)):
    return True
  return False
 retryExceptions = tuple([pymysql.InternalError, pymysql.OperationalError, pymysql.Error])
 return make_retry_decorator(timeoutSec=timeoutSec, initialRetryDelaySec=0.1, maxRetryDelaySec=10, retryExceptions=retryExceptions, retryFilter=retryFilter, logger=logger)

def retrySQL ( timeoutSec = ( 60 * 5 ) , logger = None ) : if ( logger is None ) : logger = logging . getLogger ( __name__ ) def retryFilter ( e , args , kwargs ) : if isinstance ( e , ( pymysql . InternalError , pymysql . OperationalError ) ) : if ( e . args and ( e . args [ 0 ] in _ALL_RETRIABLE_ERROR_CODES ) ) : return True elif isinstance ( e , pymysql . Error ) : if ( e . args and inspect . isclass ( e . args [ 0 ] ) and issubclass ( e . args [ 0 ] , socket_error ) ) : return True return False retryExceptions = tuple ( [ pymysql . InternalError , pymysql . OperationalError , pymysql . Error ] ) return make_retry_decorator ( timeoutSec = timeoutSec , initialRetryDelaySec = 0.1 , maxRetryDelaySec = 10 , retryExceptions = retryExceptions , retryFilter = retryFilter , logger = logger )
return a closure suitable for use as a decorator for retrying a pymysql dao function on certain failures that warrant retries .