Skip to content

Commit 807844d

Browse files
author
Mark Ruvald Pedersen
committed
Workaround race condition in python's rmtree
Python's shutil.rmtree() has a FileNotFoundError race condition, which has only been recently fixed upstream as of 3.11.8; see [1]. We have run into this race during FLOW-219, so we must workaround it since a very modern python can't be assumed. The race seems to be occur about git's garbage collection lock file since it only exists temporarily. rbgit is already ephemeral, so we don't even need GC. [1] python/cpython#14064
1 parent 44181ed commit 807844d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/git_recycle_bin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def __init__(self, prog):
437437

438438
if args.rm_tmp and os.path.exists(rbgit_dir):
439439
printer.high_level(f"Deleting local bin repo, {rbgit_dir}, to free-up disk-space.", file=sys.stderr)
440-
shutil.rmtree(rbgit_dir)
440+
shutil.rmtree(rbgit_dir, ignore_errors=True)
441441

442442
return 0
443443

src/rbgit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def init_idempotent(self):
3434
# Initialize git and configure
3535
self.cmd("init", "--initial-branch", "master", self.rbgit_work_tree)
3636
self.cmd("config", "--local", "core.autocrlf", "false")
37+
self.cmd("config", "--local", "gc.auto", "0")
3738

3839
# Exclude .rbgit from version control
3940
with open(f"{self.rbgit_dir}/info/exclude", "w") as file:

0 commit comments

Comments
 (0)