| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 653 |
| 654 def _flush_terminated_threads(self): | 654 def _flush_terminated_threads(self): |
| 655 """Flush threads that have terminated.""" | 655 """Flush threads that have terminated.""" |
| 656 running = self.running | 656 running = self.running |
| 657 self.running = [] | 657 self.running = [] |
| 658 for t in running: | 658 for t in running: |
| 659 if t.isAlive(): | 659 if t.isAlive(): |
| 660 self.running.append(t) | 660 self.running.append(t) |
| 661 else: | 661 else: |
| 662 t.join() | 662 t.join() |
| 663 sys.stdout.full_flush() | 663 sys.stdout.full_flush() # pylint: disable=E1101 |
| 664 if self.progress: | 664 if self.progress: |
| 665 self.progress.update(1, t.item.name) | 665 self.progress.update(1, t.item.name) |
| 666 assert not t.item.name in self.ran | 666 assert not t.item.name in self.ran |
| 667 if not t.item.name in self.ran: | 667 if not t.item.name in self.ran: |
| 668 self.ran.append(t.item.name) | 668 self.ran.append(t.item.name) |
| 669 | 669 |
| 670 def _run_one_task(self, task_item, args, kwargs): | 670 def _run_one_task(self, task_item, args, kwargs): |
| 671 if self.jobs > 1: | 671 if self.jobs > 1: |
| 672 # Start the thread. | 672 # Start the thread. |
| 673 index = len(self.ran) + len(self.running) + 1 | 673 index = len(self.ran) + len(self.running) + 1 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 703 logging.info('Caught exception in thread %s' % self.item.name) | 703 logging.info('Caught exception in thread %s' % self.item.name) |
| 704 logging.info(str(sys.exc_info())) | 704 logging.info(str(sys.exc_info())) |
| 705 work_queue.exceptions.put(sys.exc_info()) | 705 work_queue.exceptions.put(sys.exc_info()) |
| 706 logging.info('Task %s done' % self.item.name) | 706 logging.info('Task %s done' % self.item.name) |
| 707 | 707 |
| 708 work_queue.ready_cond.acquire() | 708 work_queue.ready_cond.acquire() |
| 709 try: | 709 try: |
| 710 work_queue.ready_cond.notifyAll() | 710 work_queue.ready_cond.notifyAll() |
| 711 finally: | 711 finally: |
| 712 work_queue.ready_cond.release() | 712 work_queue.ready_cond.release() |
| OLD | NEW |