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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 logging.info(item.name) | 694 logging.info(item.name) |
695 self.item = item | 695 self.item = item |
696 self.index = index | 696 self.index = index |
697 self.args = args | 697 self.args = args |
698 self.kwargs = kwargs | 698 self.kwargs = kwargs |
699 | 699 |
700 def run(self): | 700 def run(self): |
701 """Runs in its own thread.""" | 701 """Runs in its own thread.""" |
702 logging.debug('running(%s)' % self.item.name) | 702 logging.debug('running(%s)' % self.item.name) |
703 work_queue = self.kwargs['work_queue'] | 703 work_queue = self.kwargs['work_queue'] |
704 # It's necessary to catch all exceptions. | |
705 # pylint: disable=W0703 | |
706 try: | 704 try: |
707 self.item.run(*self.args, **self.kwargs) | 705 self.item.run(*self.args, **self.kwargs) |
708 except Exception: | 706 except Exception: |
709 # Catch exception location. | 707 # Catch exception location. |
710 logging.info('Caught exception in thread %s' % self.item.name) | 708 logging.info('Caught exception in thread %s' % self.item.name) |
711 logging.info(str(sys.exc_info())) | 709 logging.info(str(sys.exc_info())) |
712 work_queue.exceptions.put(sys.exc_info()) | 710 work_queue.exceptions.put(sys.exc_info()) |
713 logging.info('Task %s done' % self.item.name) | 711 logging.info('Task %s done' % self.item.name) |
714 | 712 |
715 work_queue.ready_cond.acquire() | 713 work_queue.ready_cond.acquire() |
716 try: | 714 try: |
717 work_queue.ready_cond.notifyAll() | 715 work_queue.ready_cond.notifyAll() |
718 finally: | 716 finally: |
719 work_queue.ready_cond.release() | 717 work_queue.ready_cond.release() |
OLD | NEW |