mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Add thread locking around GetCachePath().
BUG=406662 R=cmp@chromium.org, agable@chromium.org Review URL: https://codereview.chromium.org/469073004 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@291569 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@@ -12,6 +12,7 @@ import optparse
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
import shutil
|
||||
import subprocess
|
||||
@@ -144,6 +145,7 @@ class Mirror(object):
|
||||
gsutil_exe = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
'third_party', 'gsutil', 'gsutil')
|
||||
cachepath_lock = threading.Lock()
|
||||
|
||||
def __init__(self, url, refs=None, print_func=None):
|
||||
self.url = url
|
||||
@@ -202,6 +204,7 @@ class Mirror(object):
|
||||
|
||||
@classmethod
|
||||
def GetCachePath(cls):
|
||||
cls.cachepath_lock.acquire()
|
||||
if not hasattr(cls, 'cachepath'):
|
||||
try:
|
||||
cachepath = subprocess.check_output(
|
||||
@@ -209,8 +212,10 @@ class Mirror(object):
|
||||
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')
|
||||
|
||||
def RunGit(self, cmd, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user