From 8442308eb5c1aea87292fb637dd75504009fd2d8 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Sat, 13 Jul 2024 22:34:49 +0100 Subject: [PATCH] include Timeout errors in bad_ids and close future on raise --- src/gphotos_sync/GooglePhotosDownload.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gphotos_sync/GooglePhotosDownload.py b/src/gphotos_sync/GooglePhotosDownload.py index 50e5291..01c1d48 100644 --- a/src/gphotos_sync/GooglePhotosDownload.py +++ b/src/gphotos_sync/GooglePhotosDownload.py @@ -15,7 +15,7 @@ import requests from requests.adapters import HTTPAdapter -from requests.exceptions import RequestException +from requests.exceptions import RequestException, Timeout from urllib3.util.retry import Retry from gphotos_sync import Utils @@ -344,12 +344,16 @@ def do_download_complete( # already handled in urllib3 # Items that cause API errors go in a BadIds file which must - # be deleted to retry these items. - if isinstance(e, RequestException): + # be deleted to retry these items. Also do this for timeouts + # which have been reported as happening on files missing on + # the server. See #480 and #488 + if isinstance(e, RequestException) or isinstance(e, Timeout): self.bad_ids.add_id( media_item.relative_path, media_item.id, media_item.url, e ) else: + # don't leave the thread hanging if we are going to raise + del self.pool_future_to_media[future] raise e else: self._db.put_downloaded(media_item.id)