Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 47315 - buffered output of emerge
Summary: buffered output of emerge
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All All
: High minor (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-09 01:50 UTC by Denis Knauf
Modified: 2004-04-11 16:46 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Denis Knauf 2004-04-09 01:50:25 UTC
i tried to pipe the output from emerge through an other programm. i want to have a nearly realtime output, but python buffered the output of emerge.

Reproducible: Always
Steps to Reproduce:
example:  emerge -pv world | ruby -ne 'print $_'

Actual Results:  
the output would be written to screen, when emerge will exit, not immediate. 
the reason is that python buffered the output. it's the standard approach. 

Expected Results:  
output should be for direct reading. Also, if piped through an other program. 

the first line of /usr/bin/emerge can be edit to fix the problem: 
replace: #!/usr/bin/python -O 
with:    #!/usr/bin/python -uO
Comment 1 Jason Stubbs (RETIRED) gentoo-dev 2004-04-09 19:18:34 UTC
Python buffers and flushes on every new-line by default. The code for writing the spinner while calculating dependencies must explicitly flush the buffer due to this. Perhaps ruby is buffering?
Comment 2 Denis Knauf 2004-04-10 03:17:06 UTC
try this:
$ python -u $(which emerge) -pv world | perl -ne 'print $_'
an try this:
$ python    $(which emerge) -pv world | perl -ne 'print $_'
first put out like it comes.
second put out, if python will exit.
perl is in both the same. you can replace perl with ruby, it happens the same.
it must be python, which buffers.
Comment 3 Jason Stubbs (RETIRED) gentoo-dev 2004-04-10 09:12:19 UTC
Testing gave me as follows:

-O  >file -ep  11.328
-O  >file -edp 11.385
-O        -ep  12.377
-O        -edp 39.023
-O  total      74.113

-Ou >file -ep  11.366
-Ou >file -edp 11.432
-Ou       -ep  12.399
-Ou       -edp 41.626
-Ou total      76.823

Approximately a 3.5% performance loss overall.
Nick, what do you think?
Comment 4 Nicholas Jones (RETIRED) gentoo-dev 2004-04-11 16:46:16 UTC
This is a system level buffer. You're piping. You yield to
how the system choses to do things. Normally a 4k buffer.
Doesn't matter what portage does.