mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 18:53:21 +01:00
retry HTTP requests for more exception classes
This commit is contained in:
parent
c2e59b9a7d
commit
b828473aa3
@ -64,9 +64,12 @@ class Extractor():
|
||||
while True:
|
||||
try:
|
||||
response = self.session.request(method, url, **kwargs)
|
||||
except (requests.ConnectionError, requests.Timeout) as exc:
|
||||
except (requests.exceptions.ConnectionError,
|
||||
requests.exceptions.Timeout,
|
||||
requests.exceptions.ChunkedEncodingError,
|
||||
requests.exceptions.ContentDecodingError) as exc:
|
||||
msg = exc
|
||||
except requests.exceptions.RequestException as exc:
|
||||
except (requests.exceptions.RequestException) as exc:
|
||||
raise exception.HttpError(exc)
|
||||
else:
|
||||
code = response.status_code
|
||||
@ -79,11 +82,11 @@ class Extractor():
|
||||
if code < 500 and code != 429:
|
||||
break
|
||||
|
||||
self.log.debug("%s (%d/%d)", msg, tries + 1, retries)
|
||||
tries += 1
|
||||
self.log.debug("%s (%d/%d)", msg, tries, retries)
|
||||
if tries >= retries:
|
||||
break
|
||||
time.sleep(2 ** tries)
|
||||
tries += 1
|
||||
|
||||
raise exception.HttpError(msg)
|
||||
|
||||
|
@ -60,7 +60,10 @@ class Job():
|
||||
res = str(exc) or "resource (gallery/image/user)"
|
||||
log.error("The %s at '%s' does not exist", res, self.url)
|
||||
except exception.HttpError as exc:
|
||||
log.error("HTTP request failed: %s", exc)
|
||||
err = exc.args[0]
|
||||
if isinstance(err, Exception):
|
||||
err = "{}: {}".format(err.__class__.__name__, err)
|
||||
log.error("HTTP request failed: %s", err)
|
||||
except exception.FormatError as exc:
|
||||
err, obj = exc.args
|
||||
log.error("Applying %s format string failed: %s: %s",
|
||||
|
Loading…
Reference in New Issue
Block a user