comparison mxtool/mx.py @ 15871:11bf5b8973c9

mx: drain all subprocess output to callables before returning from mx.run
author Doug Simon <doug.simon@oracle.com>
date Sat, 24 May 2014 00:23:52 +0200
parents f04a541af3c9
children a5c5b4aa79ca
comparison
equal deleted inserted replaced
15870:fe608a56e3f7 15871:11bf5b8973c9
1512 stream.close() 1512 stream.close()
1513 stdout = out if not callable(out) else subprocess.PIPE 1513 stdout = out if not callable(out) else subprocess.PIPE
1514 stderr = err if not callable(err) else subprocess.PIPE 1514 stderr = err if not callable(err) else subprocess.PIPE
1515 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env) 1515 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env)
1516 sub = _addSubprocess(p, args) 1516 sub = _addSubprocess(p, args)
1517 joiners = []
1517 if callable(out): 1518 if callable(out):
1518 t = Thread(target=redirect, args=(p.stdout, out)) 1519 t = Thread(target=redirect, args=(p.stdout, out))
1519 # Don't make the reader thread a daemon otherwise output can be droppped 1520 # Don't make the reader thread a daemon otherwise output can be droppped
1520 t.start() 1521 t.start()
1522 joiners.append(t)
1521 if callable(err): 1523 if callable(err):
1522 t = Thread(target=redirect, args=(p.stderr, err)) 1524 t = Thread(target=redirect, args=(p.stderr, err))
1523 # Don't make the reader thread a daemon otherwise output can be droppped 1525 # Don't make the reader thread a daemon otherwise output can be droppped
1524 t.start() 1526 t.start()
1527 joiners.append(t)
1528 for t in joiners:
1529 t.join()
1525 if timeout is None or timeout == 0: 1530 if timeout is None or timeout == 0:
1526 retcode = waitOn(p) 1531 retcode = waitOn(p)
1527 else: 1532 else:
1528 if get_os() == 'windows': 1533 if get_os() == 'windows':
1529 abort('Use of timeout not (yet) supported on Windows') 1534 abort('Use of timeout not (yet) supported on Windows')