6

Given following example usage:

adapter = HTTPAdapter(max_retries=Retry(
    total=5,
    backoff_factor=0.1,
    status_forcelist=[429, 500, 502, 503, 504],
    method_whitelist=["HEAD", "GET", "OPTIONS"]
))
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
rsp = session.post(url, json=my_json, params=my_params)

I occasionally get:

('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

I would like to establish retries around this as well (related question), and I'd like to be able to test it by issuing such an error from inside the library's retry loop.

How do I do that?

Kache
  • 15,647
  • 12
  • 51
  • 79
  • 2
    Wow, so these kind of errors are, by default, not handled by Retry? Good to know! Also, it would be great to know if you solved this? – Arjan Aug 31 '21 at 11:16
  • would something like `raise http.client.RemoteDisconnected("Remote server disconnected")` work? – gs202 Jun 21 '23 at 15:27

0 Answers0