mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Do threading.Lock the Right Way.
R=cmp@chromium.org, dnj@chromium.org, iannucci@chromium.org BUG= Review URL: https://codereview.chromium.org/499003002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@291573 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
30
git_cache.py
30
git_cache.py
@@ -200,25 +200,23 @@ class Mirror(object):
|
||||
|
||||
@classmethod
|
||||
def SetCachePath(cls, cachepath):
|
||||
cls.cachepath_lock.acquire()
|
||||
setattr(cls, 'cachepath', cachepath)
|
||||
cls.cachepath_lock.release()
|
||||
with cls.cachepath_lock:
|
||||
setattr(cls, 'cachepath', cachepath)
|
||||
|
||||
@classmethod
|
||||
def GetCachePath(cls):
|
||||
cls.cachepath_lock.acquire()
|
||||
if not hasattr(cls, 'cachepath'):
|
||||
try:
|
||||
cachepath = subprocess.check_output(
|
||||
[cls.git_exe, 'config', '--global', 'cache.cachepath']).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
cachepath = None
|
||||
if not cachepath:
|
||||
cls.cachepath_lock.release()
|
||||
raise RuntimeError('No global cache.cachepath git configuration found.')
|
||||
setattr(cls, 'cachepath', cachepath)
|
||||
cls.cachepath_lock.release()
|
||||
return getattr(cls, 'cachepath')
|
||||
with cls.cachepath_lock:
|
||||
if not hasattr(cls, 'cachepath'):
|
||||
try:
|
||||
cachepath = subprocess.check_output(
|
||||
[cls.git_exe, 'config', '--global', 'cache.cachepath']).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
cachepath = None
|
||||
if not cachepath:
|
||||
raise RuntimeError(
|
||||
'No global cache.cachepath git configuration found.')
|
||||
setattr(cls, 'cachepath', cachepath)
|
||||
return getattr(cls, 'cachepath')
|
||||
|
||||
def RunGit(self, cmd, **kwargs):
|
||||
"""Run git in a subprocess."""
|
||||
|
||||
Reference in New Issue
Block a user