This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author astrand
Recipients astrand, jason.w.kim
Date 2007-10-06.07:04:59
SpamBayes Score 0.13396989
Marked as misclassified No
Message-id <1191654300.54.0.524352869774.issue1241@psf.upfronthosting.co.za>
In-reply-to
Content
Most probably, this is not a problem with the Python side or the pipes,
but the libc streams in the application. stderr is normally unbuffered,
while stdout is buffered. You can see this by running the app with grep:

$ ./a.out | grep STDOUT
STDERR sleeping 0
STDERR sleeping 1
STDERR sleeping 2
STDERR sleeping 3

If you throw in a:

setvbuf(stdout, NULL, _IONBF, 0);

things will work the way you expect:

$ ./a.out | grep STDOUT
STDERR sleeping 0
STDOUT boo 0
STDOUT sleeping 0
STDERR sleeping 1
STDOUT boo 1
History
Date User Action Args
2007-10-06 07:05:00astrandsetspambayes_score: 0.13397 -> 0.13396989
recipients: + astrand, jason.w.kim
2007-10-06 07:05:00astrandsetspambayes_score: 0.13397 -> 0.13397
messageid: <1191654300.54.0.524352869774.issue1241@psf.upfronthosting.co.za>
2007-10-06 07:05:00astrandlinkissue1241 messages
2007-10-06 07:05:00astrandcreate