From 47df1aa4f8c976cf7f580234eedf304173712f67 Mon Sep 17 00:00:00 2001 From: Francesco Frassinelli Date: Tue, 1 Oct 2024 13:34:33 +0200 Subject: [PATCH] Add backoff --- pyproject.toml | 3 ++- src/nvdb/vegobjekter.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f769da2..75974f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,8 @@ dependencies = [ "flask>=2.2.2", "hydra-core>=1.3.1", "requests>=2.28.1", - "pydantic~=1.10.14" + "pydantic~=1.10.14", + "backoff" ] description = "" license = {text = "GPL-3.0+"} diff --git a/src/nvdb/vegobjekter.py b/src/nvdb/vegobjekter.py index 0366609..a27c55a 100644 --- a/src/nvdb/vegobjekter.py +++ b/src/nvdb/vegobjekter.py @@ -1,6 +1,7 @@ import os from urllib.parse import urljoin +import backoff import requests import shapely.ops import shapely.wkt @@ -87,6 +88,9 @@ def get_start(self, **params): ).json()["metadata"]["neste"]["start"] @cache.cached(timeout=60 * 60) + @backoff.on_exception( + backoff.expo, requests.exceptions.RequestException, max_time=60 + ) def query( self, offset=0,