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
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?
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.
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?
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.