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

Side by Side Diff: gclient_utils.py

Issue 8359018: Fix a concurrency issue happening with deep dependencies when the intermediary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Generic utils.""" 5 """Generic utils."""
6 6
7 import errno 7 import errno
8 import logging 8 import logging
9 import os 9 import os
10 import Queue 10 import Queue
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 else: 164 else:
165 # Recurse. 165 # Recurse.
166 rmtree(fullpath) 166 rmtree(fullpath)
167 167
168 remove(os.rmdir, path) 168 remove(os.rmdir, path)
169 169
170 # TODO(maruel): Rename the references. 170 # TODO(maruel): Rename the references.
171 RemoveDirectory = rmtree 171 RemoveDirectory = rmtree
172 172
173 173
174 def safe_makedirs(tree):
175 """Creates the directory in a safe manner.
176
177 Because multiple threads can create these directories concurently, trap the
178 exception and pass on.
179 """
180 count = 0
181 while not os.path.exists(tree):
182 count += 1
183 try:
184 os.makedirs(tree)
185 except OSError, e:
186 # 17 POSIX, 183 Windows
187 if e.errno not in (17, 183):
188 raise
189 if count > 40:
190 # Give up.
191 raise
192
193
174 def CheckCallAndFilterAndHeader(args, always=False, **kwargs): 194 def CheckCallAndFilterAndHeader(args, always=False, **kwargs):
175 """Adds 'header' support to CheckCallAndFilter. 195 """Adds 'header' support to CheckCallAndFilter.
176 196
177 If |always| is True, a message indicating what is being done 197 If |always| is True, a message indicating what is being done
178 is printed to stdout all the time even if not output is generated. Otherwise 198 is printed to stdout all the time even if not output is generated. Otherwise
179 the message header is printed only if the call generated any ouput. 199 the message header is printed only if the call generated any ouput.
180 """ 200 """
181 stdout = kwargs.get('stdout', None) or sys.stdout 201 stdout = kwargs.get('stdout', None) or sys.stdout
182 if always: 202 if always:
183 stdout.write('\n________ running \'%s\' in \'%s\'\n' 203 stdout.write('\n________ running \'%s\' in \'%s\'\n'
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 logging.info('Caught exception in thread %s' % self.item.name) 684 logging.info('Caught exception in thread %s' % self.item.name)
665 logging.info(str(sys.exc_info())) 685 logging.info(str(sys.exc_info()))
666 work_queue.exceptions.put(sys.exc_info()) 686 work_queue.exceptions.put(sys.exc_info())
667 logging.info('_Worker.run(%s) done' % self.item.name) 687 logging.info('_Worker.run(%s) done' % self.item.name)
668 688
669 work_queue.ready_cond.acquire() 689 work_queue.ready_cond.acquire()
670 try: 690 try:
671 work_queue.ready_cond.notifyAll() 691 work_queue.ready_cond.notifyAll()
672 finally: 692 finally:
673 work_queue.ready_cond.release() 693 work_queue.ready_cond.release()
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698