Set default --lock_timeout to 5m

gclient-sync + git-cache are racy because if two different DEPS files
dependent on the same repo URL, even if depsed to different checkout
dirs, they use same git cache dir. If both checkout dirs are synced at
the same time, one of them cannot acquire a lock.

This is a cheap solution to change --lock_timeout option default value
from 0 to 5m.

R=hinoka@chromium.org
BUG=593468

Review URL: https://codereview.chromium.org/1785083005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299386 0039d316-1c4b-4281-b951-d872f2087c98
changes/60/343160/1
nodir@chromium.org 9 years ago
parent b12008466d
commit 5b48e48c1a

@ -2050,9 +2050,9 @@ def CMDsync(parser, args):
help='Don\'t bootstrap from Google Storage.')
parser.add_option('--ignore_locks', action='store_true',
help='GIT ONLY - Ignore cache locks.')
parser.add_option('--lock_timeout', type='int', default=0,
parser.add_option('--lock_timeout', type='int', default=5000,
help='GIT ONLY - Deadline (in seconds) to wait for git '
'cache lock to become available.')
'cache lock to become available. Default is %default.')
(options, args) = parser.parse_args(args)
client = GClient.LoadCurrentConfig(options)

@ -93,7 +93,6 @@ class Lockfile(object):
"""Acquire the lock.
This will block with a deadline of self.timeout seconds.
If self.timeout is zero, this is a NON-BLOCKING FAIL-FAST operation.
"""
elapsed = 0
while True:
@ -102,7 +101,7 @@ class Lockfile(object):
return
except OSError as e:
if elapsed < self.timeout:
sleep_time = min(3, self.timeout - elapsed)
sleep_time = max(10, min(3, self.timeout - elapsed))
logging.info('Could not create git cache lockfile; '
'will retry after sleep(%d).', sleep_time);
elapsed += sleep_time

Loading…
Cancel
Save