Skip to content
Permalink
Browse files
fix: properly use retry mechanism in source cache (#1564)
  • Loading branch information
johanneskoester committed Apr 5, 2022
1 parent 653d0d0 commit 624a83d1bfc592a2a1878d5191e09f6c3d7ee7c2
Showing 1 changed file with 3 additions and 4 deletions.
@@ -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:
@@ -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
@@ -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)
@@ -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):

0 comments on commit 624a83d

Please sign in to comment.