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