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

Side by Side Diff: gclient_utils.py

Issue 7885032: Add diagnostics in can an item is run multiple times (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 3 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 | « no previous file | no next file » | 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 filter_fn: A function taking a single string argument called with each line 325 filter_fn: A function taking a single string argument called with each line
326 of the subprocess2's output. Each line has the trailing newline 326 of the subprocess2's output. Each line has the trailing newline
327 character trimmed. 327 character trimmed.
328 stdout: Can be any bufferable output. 328 stdout: Can be any bufferable output.
329 329
330 stderr is always redirected to stdout. 330 stderr is always redirected to stdout.
331 """ 331 """
332 assert print_stdout or filter_fn 332 assert print_stdout or filter_fn
333 stdout = stdout or sys.stdout 333 stdout = stdout or sys.stdout
334 filter_fn = filter_fn or (lambda x: None) 334 filter_fn = filter_fn or (lambda x: None)
335 assert not 'stderr' in kwargs
336 kid = subprocess2.Popen( 335 kid = subprocess2.Popen(
337 args, bufsize=0, stdout=subprocess2.PIPE, stderr=subprocess2.STDOUT, 336 args, bufsize=0, stdout=subprocess2.PIPE, stderr=subprocess2.STDOUT,
338 **kwargs) 337 **kwargs)
339 338
340 # Do a flush of stdout before we begin reading from the subprocess2's stdout 339 # Do a flush of stdout before we begin reading from the subprocess2's stdout
341 stdout.flush() 340 stdout.flush()
342 341
343 # Also, we need to forward stdout to prevent weird re-ordering of output. 342 # Also, we need to forward stdout to prevent weird re-ordering of output.
344 # This has to be done on a per byte basis to make sure it is not buffered: 343 # This has to be done on a per byte basis to make sure it is not buffered:
345 # normally buffering is done for each line, but if svn requests input, no 344 # normally buffering is done for each line, but if svn requests input, no
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 running = self.running 580 running = self.running
582 self.running = [] 581 self.running = []
583 for t in running: 582 for t in running:
584 if t.isAlive(): 583 if t.isAlive():
585 self.running.append(t) 584 self.running.append(t)
586 else: 585 else:
587 t.join() 586 t.join()
588 sys.stdout.full_flush() # pylint: disable=E1101 587 sys.stdout.full_flush() # pylint: disable=E1101
589 if self.progress: 588 if self.progress:
590 self.progress.update(1, t.item.name) 589 self.progress.update(1, t.item.name)
591 assert not t.item.name in self.ran 590 if t.item.name in self.ran:
591 raise Error(
592 'gclient is confused, "%s" is already in "%s"' % (
593 t.item.name, ', '.join(self.ran)))
592 if not t.item.name in self.ran: 594 if not t.item.name in self.ran:
593 self.ran.append(t.item.name) 595 self.ran.append(t.item.name)
594 596
595 def _run_one_task(self, task_item, args, kwargs): 597 def _run_one_task(self, task_item, args, kwargs):
596 if self.jobs > 1: 598 if self.jobs > 1:
597 # Start the thread. 599 # Start the thread.
598 index = len(self.ran) + len(self.running) + 1 600 index = len(self.ran) + len(self.running) + 1
599 new_thread = self._Worker(task_item, index, args, kwargs) 601 new_thread = self._Worker(task_item, index, args, kwargs)
600 self.running.append(new_thread) 602 self.running.append(new_thread)
601 new_thread.start() 603 new_thread.start()
(...skipping 26 matching lines...) Expand all
628 logging.info('Caught exception in thread %s' % self.item.name) 630 logging.info('Caught exception in thread %s' % self.item.name)
629 logging.info(str(sys.exc_info())) 631 logging.info(str(sys.exc_info()))
630 work_queue.exceptions.put(sys.exc_info()) 632 work_queue.exceptions.put(sys.exc_info())
631 logging.info('Task %s done' % self.item.name) 633 logging.info('Task %s done' % self.item.name)
632 634
633 work_queue.ready_cond.acquire() 635 work_queue.ready_cond.acquire()
634 try: 636 try:
635 work_queue.ready_cond.notifyAll() 637 work_queue.ready_cond.notifyAll()
636 finally: 638 finally:
637 work_queue.ready_cond.release() 639 work_queue.ready_cond.release()
OLDNEW
« 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