Skip to content

Commit

Permalink
fix: properly use retry mechanism in source cache (#1564)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Apr 5, 2022
1 parent 653d0d0 commit 624a83d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions snakemake/sourcecache.py
Expand Up @@ -346,7 +346,7 @@ def runtime_cache_path(self):

def open(self, source_file, mode="r"):
cache_entry = self._cache(source_file)
return self._open(LocalSourceFile(cache_entry), mode)
return self._open_local_or_remote(LocalSourceFile(cache_entry), mode)

def exists(self, source_file):
try:
Expand Down Expand Up @@ -378,7 +378,7 @@ def _cache(self, source_file):

def _do_cache(self, source_file, cache_entry):
# open from origin
with self._open(source_file, "rb") as source:
with self._open_local_or_remote(source_file, "rb") as source:
tmp_source = tempfile.NamedTemporaryFile(
prefix=str(cache_entry),
delete=False, # no need to delete since we move it below
Expand All @@ -398,7 +398,7 @@ def _do_cache(self, source_file, cache_entry):
os.utime(cache_entry, times=(mtime, mtime))

def _open_local_or_remote(self, source_file, mode):
from retry import retry_call
from retry.api import retry_call

if source_file.is_local:
return self._open(source_file, mode)
Expand All @@ -409,7 +409,6 @@ def _open_local_or_remote(self, source_file, mode):
tries=3,
delay=3,
backoff=2,
logger=logger,
)

def _open(self, source_file, mode):
Expand Down

0 comments on commit 624a83d

Please sign in to comment.