handle thumbnail download base exception, #281

This commit is contained in:
simon
2022-08-12 12:58:39 +07:00
parent 25f1539816
commit 7c3bfa94f3

View File

@@ -40,13 +40,13 @@ class ThumbManagerBase:
for i in range(3): for i in range(3):
try: try:
response = requests.get(url, stream=True) response = requests.get(url, stream=True, timeout=5)
if response.ok: if response.ok:
return Image.open(response.raw) return Image.open(response.raw)
if response.status_code == 404: if response.status_code == 404:
return self.get_fallback() return self.get_fallback()
except ConnectionError: except requests.exceptions.RequestException:
print(f"{self.item_id}: retry thumbnail download {url}") print(f"{self.item_id}: retry thumbnail download {url}")
sleep((i + 1) ** i) sleep((i + 1) ** i)