| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 in_line = '' | 353 in_line = '' |
| 354 while in_byte: | 354 while in_byte: |
| 355 if in_byte != '\r': | 355 if in_byte != '\r': |
| 356 if print_stdout: | 356 if print_stdout: |
| 357 stdout.write(in_byte) | 357 stdout.write(in_byte) |
| 358 if in_byte != '\n': | 358 if in_byte != '\n': |
| 359 in_line += in_byte | 359 in_line += in_byte |
| 360 else: | 360 else: |
| 361 filter_fn(in_line) | 361 filter_fn(in_line) |
| 362 in_line = '' | 362 in_line = '' |
| 363 else: |
| 364 filter_fn(in_line) |
| 365 in_line = '' |
| 363 in_byte = kid.stdout.read(1) | 366 in_byte = kid.stdout.read(1) |
| 364 # Flush the rest of buffered output. This is only an issue with | 367 # Flush the rest of buffered output. This is only an issue with |
| 365 # stdout/stderr not ending with a \n. | 368 # stdout/stderr not ending with a \n. |
| 366 if len(in_line): | 369 if len(in_line): |
| 367 filter_fn(in_line) | 370 filter_fn(in_line) |
| 368 rv = kid.wait() | 371 rv = kid.wait() |
| 369 except KeyboardInterrupt: | 372 except KeyboardInterrupt: |
| 370 print >> sys.stderr, 'Failed while running "%s"' % ' '.join(args) | 373 print >> sys.stderr, 'Failed while running "%s"' % ' '.join(args) |
| 371 raise | 374 raise |
| 372 | 375 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 logging.info('Caught exception in thread %s' % self.item.name) | 670 logging.info('Caught exception in thread %s' % self.item.name) |
| 668 logging.info(str(sys.exc_info())) | 671 logging.info(str(sys.exc_info())) |
| 669 work_queue.exceptions.put(sys.exc_info()) | 672 work_queue.exceptions.put(sys.exc_info()) |
| 670 logging.info('_Worker.run(%s) done' % self.item.name) | 673 logging.info('_Worker.run(%s) done' % self.item.name) |
| 671 | 674 |
| 672 work_queue.ready_cond.acquire() | 675 work_queue.ready_cond.acquire() |
| 673 try: | 676 try: |
| 674 work_queue.ready_cond.notifyAll() | 677 work_queue.ready_cond.notifyAll() |
| 675 finally: | 678 finally: |
| 676 work_queue.ready_cond.release() | 679 work_queue.ready_cond.release() |
| OLD | NEW |