def retry_with_delay(f, delay=<NUM_LIT>):
@wraps(f)<EOL>def inner(*args, **kwargs):<EOL><INDENT>kwargs['<STR_LIT>'] = <NUM_LIT:5><EOL>remaining = get_retries() + <NUM_LIT:1><EOL>while remaining:<EOL><INDENT>remaining -= <NUM_LIT:1><EOL>try:<EOL><INDENT>return f(*args, **kwargs)<EOL><DEDENT>except (requests.ConnectionError, requests.Timeout):<EOL><INDENT>if not remaining:<EOL><INDENT>raise<EOL><DEDENT>gevent.sleep(delay)<EOL><DEDENT><DEDENT><DEDENT>return inner<EOL>
Retry the wrapped requests.request function in case of ConnectionError.
Optionally limit the number of retries or set the delay between retries.