| OLD | NEW |
| 1 # coding=utf8 | 1 # coding=utf8 |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 """Collection of subprocess wrapper functions. | 5 """Collection of subprocess wrapper functions. |
| 6 | 6 |
| 7 In theory you shouldn't need anything else in subprocess, or this module failed. | 7 In theory you shouldn't need anything else in subprocess, or this module failed. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import cStringIO | 10 import cStringIO |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 # Pipe but no input, make sure it's closed. | 288 # Pipe but no input, make sure it's closed. |
| 289 self.stdin.close() | 289 self.stdin.close() |
| 290 for t in threads.itervalues(): | 290 for t in threads.itervalues(): |
| 291 t.start() | 291 t.start() |
| 292 | 292 |
| 293 timed_out = False | 293 timed_out = False |
| 294 try: | 294 try: |
| 295 # This thread needs to be optimized for speed. | 295 # This thread needs to be optimized for speed. |
| 296 while threads: | 296 while threads: |
| 297 item = queue.get() | 297 item = queue.get() |
| 298 if item[0] is 'stdout': | 298 if item[0] == 'stdout': |
| 299 self.stdout_cb(item[1]) | 299 self.stdout_cb(item[1]) |
| 300 elif item[0] is 'stderr': | 300 elif item[0] == 'stderr': |
| 301 self.stderr_cb(item[1]) | 301 self.stderr_cb(item[1]) |
| 302 else: | 302 else: |
| 303 # A thread terminated. | 303 # A thread terminated. |
| 304 threads[item].join() | 304 threads[item].join() |
| 305 del threads[item] | 305 del threads[item] |
| 306 if item == 'wait': | 306 if item == 'wait': |
| 307 # Terminate the timeout thread if necessary. | 307 # Terminate the timeout thread if necessary. |
| 308 done.set() | 308 done.set() |
| 309 elif item == 'timeout' and not timed_out and self.poll() is None: | 309 elif item == 'timeout' and not timed_out and self.poll() is None: |
| 310 logging.debug('Timed out after %fs: killing' % self.timeout) | 310 logging.debug('Timed out after %fs: killing' % self.timeout) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 440 |
| 441 - Throws if return code is not 0. | 441 - Throws if return code is not 0. |
| 442 - Works even prior to python 2.7. | 442 - Works even prior to python 2.7. |
| 443 - Blocks stdin by default if not specified since no output will be visible. | 443 - Blocks stdin by default if not specified since no output will be visible. |
| 444 - As per doc, "The stdout argument is not allowed as it is used internally." | 444 - As per doc, "The stdout argument is not allowed as it is used internally." |
| 445 """ | 445 """ |
| 446 kwargs.setdefault('stdin', VOID) | 446 kwargs.setdefault('stdin', VOID) |
| 447 if 'stdout' in kwargs: | 447 if 'stdout' in kwargs: |
| 448 raise ValueError('stdout argument not allowed, it will be overridden.') | 448 raise ValueError('stdout argument not allowed, it will be overridden.') |
| 449 return check_call_out(args, stdout=PIPE, **kwargs)[0] | 449 return check_call_out(args, stdout=PIPE, **kwargs)[0] |
| OLD | NEW |