Mercurial > hg
comparison mercurial/util.py @ 23030:a0e0aa12b672
util.system: avoid buffering of subprocess output when it is piped
util.system() copies subprocess' output through pipe if output file is not
stdout. Because a file iterator has internal buffering, output won't be
flushed until enough data is available. Therefore, it could easily miss
important messages such as "waiting for lock".
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 30 Aug 2014 17:38:14 +0200 |
parents | 56e04741bbf1 |
children | c312ef382033 |
comparison
equal
deleted
inserted
replaced
23029:149fc8a44184 | 23030:a0e0aa12b672 |
---|---|
647 env=env, cwd=cwd) | 647 env=env, cwd=cwd) |
648 else: | 648 else: |
649 proc = subprocess.Popen(cmd, shell=True, close_fds=closefds, | 649 proc = subprocess.Popen(cmd, shell=True, close_fds=closefds, |
650 env=env, cwd=cwd, stdout=subprocess.PIPE, | 650 env=env, cwd=cwd, stdout=subprocess.PIPE, |
651 stderr=subprocess.STDOUT) | 651 stderr=subprocess.STDOUT) |
652 for line in proc.stdout: | 652 while True: |
653 line = proc.stdout.readline() | |
654 if not line: | |
655 break | |
653 out.write(line) | 656 out.write(line) |
654 proc.wait() | 657 proc.wait() |
655 rc = proc.returncode | 658 rc = proc.returncode |
656 if sys.platform == 'OpenVMS' and rc & 1: | 659 if sys.platform == 'OpenVMS' and rc & 1: |
657 rc = 0 | 660 rc = 0 |