OLD | NEW |
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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 490 |
491 @property | 491 @property |
492 def name(self): | 492 def name(self): |
493 return self._name | 493 return self._name |
494 | 494 |
495 @property | 495 @property |
496 @lockedmethod | 496 @lockedmethod |
497 def requirements(self): | 497 def requirements(self): |
498 return tuple(self._requirements) | 498 return tuple(self._requirements) |
499 | 499 |
| 500 @lockedmethod |
| 501 def add_requirement(self, new): |
| 502 self._requirements.add(new) |
| 503 |
500 | 504 |
501 class ExecutionQueue(object): | 505 class ExecutionQueue(object): |
502 """Runs a set of WorkItem that have interdependencies and were WorkItem are | 506 """Runs a set of WorkItem that have interdependencies and were WorkItem are |
503 added as they are processed. | 507 added as they are processed. |
504 | 508 |
505 In gclient's case, Dependencies sometime needs to be run out of order due to | 509 In gclient's case, Dependencies sometime needs to be run out of order due to |
506 From() keyword. This class manages that all the required dependencies are run | 510 From() keyword. This class manages that all the required dependencies are run |
507 before running each one. | 511 before running each one. |
508 | 512 |
509 Methods of this class are thread safe. | 513 Methods of this class are thread safe. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 logging.info('Caught exception in thread %s' % self.item.name) | 667 logging.info('Caught exception in thread %s' % self.item.name) |
664 logging.info(str(sys.exc_info())) | 668 logging.info(str(sys.exc_info())) |
665 work_queue.exceptions.put(sys.exc_info()) | 669 work_queue.exceptions.put(sys.exc_info()) |
666 logging.info('_Worker.run(%s) done' % self.item.name) | 670 logging.info('_Worker.run(%s) done' % self.item.name) |
667 | 671 |
668 work_queue.ready_cond.acquire() | 672 work_queue.ready_cond.acquire() |
669 try: | 673 try: |
670 work_queue.ready_cond.notifyAll() | 674 work_queue.ready_cond.notifyAll() |
671 finally: | 675 finally: |
672 work_queue.ready_cond.release() | 676 work_queue.ready_cond.release() |
OLD | NEW |