Skip to content

Commit b4fd74c

Browse files
committed
Improve description of backoff sequence in db.loose
The sequence of backoff wait times used in `gitdb.db.loose` is quadratic rather than exponential, as discussed in: #115 (comment) This corrects the variable name by making it more general, and the comment by having it explicitly describe the backoff as quadratic. This is conceptually related to GitoxideLabs/gitoxide#1815, but this is a non-breaking change, as no interfaces are affected: only a local variable and comment.
1 parent 9e68ea1 commit b4fd74c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: gitdb/db/loose.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,16 @@ def store(self, istream):
230230
# end rename only if needed
231231

232232
# Ensure rename is actually done and file is stable
233-
# Retry up to 14 times - exponential wait & retry in ms.
233+
# Retry up to 14 times - quadratic wait & retry in ms.
234234
# The total maximum wait time is 1000ms, which should be vastly enough for the
235235
# OS to return and commit the file to disk.
236-
for exp_backoff_ms in [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 181]:
236+
for backoff_ms in [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 181]:
237237
with suppress(PermissionError):
238238
# make sure its readable for all ! It started out as rw-- tmp file
239239
# but needs to be rwrr
240240
chmod(obj_path, self.new_objects_mode)
241241
break
242-
time.sleep(exp_backoff_ms / 1000.0)
242+
time.sleep(backoff_ms / 1000.0)
243243
else:
244244
raise PermissionError(
245245
"Impossible to apply `chmod` to file {}".format(obj_path)

0 commit comments

Comments
 (0)