def request ( method , url , * * kwargs ) : retries = kwargs . pop ( 'retries' , None ) with Session ( retries = retries ) as session : return session . request ( method = method , url = url , * * kwargs )
python requests set maximum retries
Wrapper for the requests . request () function . It accepts the same arguments as the original plus an optional retries that overrides the default retry mechanism .
def request(method, url, **kwargs):
    """
    Wrapper for the `requests.request()` function.
    It accepts the same arguments as the original, plus an optional `retries`
    that overrides the default retry mechanism.
    """
    retries = kwargs.pop('retries', None)
    with Session(retries=retries) as session:
        return session.request(method=method, url=url, **kwargs)