Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: git_cache.py

Issue 469073004: Add thread locking around GetCachePath(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cache.py
diff --git a/git_cache.py b/git_cache.py
index d36686485f550cc8a3c18606a41e193c7978b7ef..1ac9a41c23f56aa147a0131eda6eb9cb574ef864 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -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):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698