From 32103ac95a7004b125c2eb267bfe678390a8bccc Mon Sep 17 00:00:00 2001 From: Bartek Ogryczak Date: Tue, 24 Oct 2017 01:55:42 -0700 Subject: [PATCH] More HTTP status codes to retry on (#4473) * Add `--retry-status ` to allow specifying custom HTTP staus codes to retry on. This is useful for AWS S3 or Cloudflare, which at times return codes other than 503 for itermitent failures. * stripping option related code, hardcoding the statuses * Reword the news file * changing ndash to regular ascii dash --- news/4473.feature | 4 ++++ src/pip/_internal/download.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 news/4473.feature diff --git a/news/4473.feature b/news/4473.feature new file mode 100644 index 00000000000..5e93d322496 --- /dev/null +++ b/news/4473.feature @@ -0,0 +1,4 @@ +pip now retries on more HTTP status codes, for intermittent failures. + +Previously, it only retried on the standard 503. Now, it also retries on 500 +(transient failures on AWS S3), 520 and 527 (transient failures on Cloudflare). diff --git a/src/pip/_internal/download.py b/src/pip/_internal/download.py index 621dea7e3ce..180ea77bfaf 100644 --- a/src/pip/_internal/download.py +++ b/src/pip/_internal/download.py @@ -348,7 +348,9 @@ def __init__(self, *args, **kwargs): # connection got interrupted in some way. A 503 error in general # is typically considered a transient error so we'll go ahead and # retry it. - status_forcelist=[503], + # A 500 may indicate transient errror in Amazon S3 + # A 520 or 527 - may indicate transient errror in CloudFlare + status_forcelist=[500, 503, 520, 527], # Add a small amount of back off between failed requests in # order to prevent hammering the service.