Skip to content

Commit 1e2237c

Browse files
Merge pull request #271 from stanfordnmbl/filenotfounderror-retry
`FileNotFoundError` retry: don't throw at the end of retries
2 parents f2dffdb + a3ffbd9 commit 1e2237c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

mcserver/zipsession_v2.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,18 @@ def rmtree_with_retry(path, max_retries=5, backoff=0.1):
336336
shutil.rmtree(path)
337337
return
338338

339-
except (FileNotFoundError, PermissionError, OSError) as e:
339+
except (PermissionError, OSError) as e:
340340
if attempt == max_retries - 1:
341341
raise
342342
time.sleep(backoff * (2**attempt))
343343

344+
except FileNotFoundError as e:
345+
# In case we've made it here, we've made a best effort to delete
346+
# and it's likely gone.
347+
if attempt == max_retries - 1:
348+
return
349+
time.sleep(backoff * (2**attempt))
350+
344351
def zipdir_contents_with_retry(dir_path, zip_path, max_retries=5, backoff=0.1):
345352
"""
346353
Given a source dir_path and a target zip_path, zip the folder with

0 commit comments

Comments
 (0)