diff options
| author | John Estabrook <jestabro@vyos.io> | 2026-02-10 11:48:09 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-10 11:48:09 -0600 |
| commit | 4824a493701180b2d9eb37bce6420cf5ccf602c8 (patch) | |
| tree | 009c8b124bc3851917341098a67edb4ecab3c229 /python | |
| parent | d9aa7405a3e0259370b86caa7ea704f0022faf32 (diff) | |
| parent | 8262f78e0013291f747203e0b3768bb412bf1aed (diff) | |
| download | vyos-1x-4824a493701180b2d9eb37bce6420cf5ccf602c8.tar.gz vyos-1x-4824a493701180b2d9eb37bce6420cf5ccf602c8.zip | |
Merge pull request #4980 from alexandr-san4ez/T7945-current
update-check: T7945: Improve reliability during early boot and error handling
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/version.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/python/vyos/version.py b/python/vyos/version.py index 01986e4da..d62778c4b 100644 --- a/python/vyos/version.py +++ b/python/vyos/version.py @@ -34,6 +34,7 @@ import os import requests import vyos.defaults from vyos.system.image import is_live_boot +from urllib3.util import retry from vyos.utils.file import read_file from vyos.utils.file import read_json @@ -124,9 +125,18 @@ def get_remote_version(url): } ] """ + headers = {} + session = requests.Session() + + # By default, `requests` lib. does not retry failed connections + # and this code implements automatic retries using the next wait time range: + # - 0.15, 0.30, 0.60, 1.20 and 2.40 seconds. + for adapter in session.adapters.values(): + adapter.max_retries = retry.Retry(total=5, backoff_factor=0.15) + try: - remote_data = requests.get(url=url, headers=headers) + remote_data = session.get(url=url, headers=headers) remote_data.raise_for_status() if remote_data.status_code != 200: return False |
