Catch timeout connection then fallback

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
Hiroshi Miura
2021-02-13 11:29:57 +09:00
parent 8bb391f63f
commit c4b488bd22
2 changed files with 5 additions and 2 deletions

View File

@@ -184,7 +184,7 @@ class QtArchives:
def _download_update_xml(self, update_xml_url):
try:
r = requests.get(update_xml_url, timeout=self.timeout)
except (ConnectionResetError, requests.exceptions.ConnectionError):
except (ConnectionResetError, requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
raise ArchiveConnectionError()
else:
if r.status_code == 200:

View File

@@ -336,7 +336,7 @@ class Cli:
target = args.target
try:
pl = PackagesList(qt_version, host, target, BASE_URL)
except requests.exceptions.ConnectionError:
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
pl = PackagesList(qt_version, host, target, random.choice(FALLBACK_URLS))
print('List Qt packages in %s for %s' % (args.qt_version, args.host))
table = Texttable()
@@ -500,6 +500,9 @@ def installer(qt_archive, base_dir, command, response_timeout=30):
except requests.exceptions.ConnectionError as e:
logger.error("Connection error: %s" % e.args)
raise e
except requests.exceptions.Timeout as e:
logger.error("Connection timeout: %s" % e.args)
raise e
else:
try:
with open(archive, 'wb') as fd: