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

Side by Side Diff: gclient_utils.py

Issue 7885008: Fix the case where a dep not processed could be set as a requirement. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: comment 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 | « gclient.py ('k') | tests/gclient_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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 return None 447 return None
448 448
449 env = {} 449 env = {}
450 execfile(config_path, env) 450 execfile(config_path, env)
451 config_dir = os.path.dirname(config_path) 451 config_dir = os.path.dirname(config_path)
452 return config_dir, env['entries'] 452 return config_dir, env['entries']
453 453
454 454
455 class WorkItem(object): 455 class WorkItem(object):
456 """One work item.""" 456 """One work item."""
457 # A list of string, each being a WorkItem name. 457 def __init__(self):
458 requirements = [] 458 # A list of string, each being a WorkItem name.
459 # A unique string representing this work item. 459 self.requirements = []
460 name = None 460 # A unique string representing this work item.
461 self.name = None
461 462
462 def run(self, work_queue): 463 def run(self, work_queue):
463 """work_queue is passed as keyword argument so it should be 464 """work_queue is passed as keyword argument so it should be
464 the last parameters of the function when you override it.""" 465 the last parameters of the function when you override it."""
465 pass 466 pass
466 467
467 468
468 class ExecutionQueue(object): 469 class ExecutionQueue(object):
469 """Runs a set of WorkItem that have interdependencies and were WorkItem are 470 """Runs a set of WorkItem that have interdependencies and were WorkItem are
470 added as they are processed. 471 added as they are processed.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 self._run_one_task(self.queued.pop(i), args, kwargs) 542 self._run_one_task(self.queued.pop(i), args, kwargs)
542 break 543 break
543 else: 544 else:
544 # Couldn't find an item that could run. Break out the outher loop. 545 # Couldn't find an item that could run. Break out the outher loop.
545 break 546 break
546 547
547 if not self.queued and not self.running: 548 if not self.queued and not self.running:
548 # We're done. 549 # We're done.
549 break 550 break
550 # We need to poll here otherwise Ctrl-C isn't processed. 551 # We need to poll here otherwise Ctrl-C isn't processed.
551 self.ready_cond.wait(10) 552 try:
553 self.ready_cond.wait(10)
554 except KeyboardInterrupt:
555 # Help debugging by printing some information:
556 print >> sys.stderr, (
557 ('\nAllowed parallel jobs: %d\n# queued: %d\nRan: %s\n'
558 'Running: %d') % (
559 self.jobs,
560 len(self.queued),
561 ', '.join(self.ran),
562 len(self.running)))
563 for i in self.queued:
564 print >> sys.stderr, '%s: %s' % (i.name, ', '.join(i.requirements))
565 raise
552 # Something happened: self.enqueue() or a thread terminated. Loop again. 566 # Something happened: self.enqueue() or a thread terminated. Loop again.
553 finally: 567 finally:
554 self.ready_cond.release() 568 self.ready_cond.release()
555 569
556 assert not self.running, 'Now guaranteed to be single-threaded' 570 assert not self.running, 'Now guaranteed to be single-threaded'
557 if not self.exceptions.empty(): 571 if not self.exceptions.empty():
558 # To get back the stack location correctly, the raise a, b, c form must be 572 # To get back the stack location correctly, the raise a, b, c form must be
559 # used, passing a tuple as the first argument doesn't work. 573 # used, passing a tuple as the first argument doesn't work.
560 e = self.exceptions.get() 574 e = self.exceptions.get()
561 raise e[0], e[1], e[2] 575 raise e[0], e[1], e[2]
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 logging.info('Caught exception in thread %s' % self.item.name) 628 logging.info('Caught exception in thread %s' % self.item.name)
615 logging.info(str(sys.exc_info())) 629 logging.info(str(sys.exc_info()))
616 work_queue.exceptions.put(sys.exc_info()) 630 work_queue.exceptions.put(sys.exc_info())
617 logging.info('Task %s done' % self.item.name) 631 logging.info('Task %s done' % self.item.name)
618 632
619 work_queue.ready_cond.acquire() 633 work_queue.ready_cond.acquire()
620 try: 634 try:
621 work_queue.ready_cond.notifyAll() 635 work_queue.ready_cond.notifyAll()
622 finally: 636 finally:
623 work_queue.ready_cond.release() 637 work_queue.ready_cond.release()
OLDNEW
« no previous file with comments | « gclient.py ('k') | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698