Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-18 Thread Lie Ryan
On 12/18/2009 8:15 AM, Chris Withers wrote: the order of the writes isn't preserved. How can I get this to be the case? You'll need to flush the std{out|err} or set them unbuffered; or you can just forget about relying on std{out|err} being ordered per write-order. --

subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Chris Withers
Hi All, I have this simple function: def execute(command): process = Popen(command.split(),stderr=STDOUT,stdout=PIPE) return process.communicate()[0] ..but my unit test for it fails: from testfixtures import tempdir,compare from unittest import TestCase class TestExecute(TestCase):

Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread exarkun
On 09:15 pm, ch...@simplistix.co.uk wrote: Hi All, I have this simple function: def execute(command): process = Popen(command.split(),stderr=STDOUT,stdout=PIPE) return process.communicate()[0] ..but my unit test for it fails: from testfixtures import tempdir,compare from unittest

Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Chris Withers
exar...@twistedmatrix.com wrote: How can I get this to be the case? You probably just need to flush stdout and stderr after each write. You set them up to go to the same underlying file descriptor, but they still each have independent buffering on top of that. Okay, but if I do:

Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread exarkun
On 09:56 pm, ch...@simplistix.co.uk wrote: exar...@twistedmatrix.com wrote: How can I get this to be the case? You probably just need to flush stdout and stderr after each write. You set them up to go to the same underlying file descriptor, but they still each have independent buffering on

Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Chris Withers
exar...@twistedmatrix.com wrote: libc is probably giving you line buffering when you use os.system (because the child process inherits the parent's stdio, and the parent's stdio is probably a pty, and that's the policy libc implements). snip Interesting, but do these assertions still hold

Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Mark Hammond
On 18/12/2009 9:33 AM, Chris Withers wrote: exar...@twistedmatrix.com wrote: libc is probably giving you line buffering when you use os.system (because the child process inherits the parent's stdio, and the parent's stdio is probably a pty, and that's the policy libc implements). snip

Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Terry Reedy
On 12/17/2009 5:33 PM, Chris Withers wrote: exar...@twistedmatrix.com wrote: libc is probably giving you line buffering when you use os.system (because the child process inherits the parent's stdio, and the parent's stdio is probably a pty, and that's the policy libc implements). snip