mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
contains_revision should respect lock_timeout attached by users
BUG=449182250,407051026 Change-Id: Icee1725cb0c0f0f4b6a757c4b381d6589486e40d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7000923 Reviewed-by: Scott Lee <ddoman@chromium.org> Commit-Queue: Xinan Lin <linxinan@chromium.org>
This commit is contained in:
12
git_cache.py
12
git_cache.py
@@ -313,22 +313,14 @@ class Mirror(object):
|
||||
self.Rename(tempdir, directory)
|
||||
return True
|
||||
|
||||
def contains_revision(self, revision):
|
||||
def contains_revision(self, revision, timeout):
|
||||
if not self.exists():
|
||||
return False
|
||||
|
||||
# This will raise LockError(), if another process is
|
||||
# 1) sync()-ing or
|
||||
# 2) calling contains_revision().
|
||||
#
|
||||
# In case (1), the caller is responsible for handling the LockError().
|
||||
# As per (2), the below gives 20 secs timeout just to cover most
|
||||
# practical cases.
|
||||
#
|
||||
# Ideally, read-write locks should be used, Then, the below would
|
||||
# - acquire the read lock immediately or
|
||||
# - raise LockError() if there is an ongoing sync()-ing.
|
||||
with lockfile.lock(self.mirror_path, timeout=20):
|
||||
with lockfile.lock(self.mirror_path, timeout=timeout):
|
||||
# If the sentinent file exists at this point, it indicates that
|
||||
# the bootstrapping process was interrupted, leaving the cache
|
||||
# entries in a bad state.
|
||||
|
||||
Reference in New Issue
Block a user