http_client¶
- lsst.analysis.tools.http_client() Generator[Session] ¶
Creates a requests session with a custom transport to support automatic retries with backoff for dealing with transient server-side issues.
Notes
The goal of the adapter defined here is to avoid premature client abends when transient server or infrastructure issues prevent good-faith attempts at accessing APIs. To the extent that we want to balance “eventually successful” HTTP requests with the desire to vacate the compute resources our process is occupying, these retries should not overstay their welcome.
The “POST” HTTP verb is not usually part of the allowed methods for retries because unlike “PUT”, “POST” is not considered idempotent by default. It is partially for this reason that a custom Retry adapter is needed, because by default “POST” requests would not be retried for status.
The backoff_factor is an exponential factor used to calculate how long to sleep between the third and subsequent tries, in seconds. The first retry is immediate and the total backoff won’t exceed backoff_max, which defaults to 120 seconds.