Skip to content

Commit

Permalink
Add retry to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Jul 8, 2023
1 parent a3bc166 commit 5460e62
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
Development
***********

- Add retry to functions

0.57.1 (28.06.2023)
*******************

Expand Down
23 changes: 22 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ python-dateutil = "^2.8.2"
rapidfuzz = "^3.1"
requests = "^2.20"
scikit-learn = "^1.0.2"
stamina = "^23.1.0"
tabulate = "^0.8"
timezonefinder = "^6.1"
tqdm = "^4.47"
Expand Down
3 changes: 3 additions & 0 deletions wetterdienst/util/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from io import BytesIO
from typing import Dict, List, Optional, Tuple, Union

import stamina
from fsspec import AbstractFileSystem
from fsspec.implementations.cached import WholeFileCacheFileSystem
from fsspec.implementations.http import HTTPFileSystem
Expand Down Expand Up @@ -57,6 +58,7 @@ def get(cls, settings, ttl: Optional[Union[int, CacheExpiry]] = CacheExpiry.NO_C
return cls.filesystems[key]


@stamina.retry(on=Exception, attempts=3)
def list_remote_files_fsspec(url: str, settings: Settings, ttl: CacheExpiry = CacheExpiry.FILEINDEX) -> List[str]:
"""
A function used to create a listing of all files of a given path on the server.
Expand All @@ -79,6 +81,7 @@ def list_remote_files_fsspec(url: str, settings: Settings, ttl: CacheExpiry = Ca
return fs.find(url)


@stamina.retry(on=Exception, attempts=3)
def download_file(
url: str, settings: Settings, ttl: Optional[Union[int, CacheExpiry]] = CacheExpiry.NO_CACHE
) -> BytesIO:
Expand Down

0 comments on commit 5460e62

Please sign in to comment.