Output from a python script to a calling program. 
Author Message
 Output from a python script to a calling program.

When I call a python script from another program, I notice several
things.

1) It sort of bunches the output. Specifically it sits and waits for a
large block of output, then prints, stops printing, sits and waits
then prints the next batch.
2) Sometimes it seems that parts of the output are printed in
different order them I would expect.

Any idea of how to fix this?



Sat, 07 Dec 2002 03:00:00 GMT  
 Output from a python script to a calling program.

Quote:
> When I call a python script from another program, I notice several
> things.

> 1) It sort of bunches the output. Specifically it sits and waits for a
> large block of output, then prints, stops printing, sits and waits
> then prints the next batch.
> 2) Sometimes it seems that parts of the output are printed in
> different order them I would expect.

   1) The -u option turns off buffering. However, performance may be lower
without buffering.

   2) You may be seeing standard output being buffered and standard error
not being buffered. So output to standard error appears before some earlier
output to standard output.

   Neil



Sat, 07 Dec 2002 03:00:00 GMT  
 Output from a python script to a calling program.


Quote:
>> When I call a python script from another program, I notice several
>> things.

>> 1) It sort of bunches the output. Specifically it sits and waits for a
>> large block of output, then prints, stops printing, sits and waits
>> then prints the next batch.
>> 2) Sometimes it seems that parts of the output are printed in
>> different order them I would expect.

>   1) The -u option turns off buffering. However, performance may be lower
>without buffering.

>   2) You may be seeing standard output being buffered and standard error
>not being buffered. So output to standard error appears before some earlier
>output to standard output.

>   Neil

Yep, that did the trick. The question now is can I turn off buffering
from inside the script?


Sun, 08 Dec 2002 03:00:00 GMT  
 Output from a python script to a calling program.

Quote:
> Yep, that did the trick. The question now is can I turn off buffering
> from inside the script?

   You can call flush on the outputs when you want output to appear.

   You can open the console with buffer size set to 0 and then assign this
file to sys.stdout and sys.stderr.

   Neil



Sun, 08 Dec 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. rxvt + python problem: script output buffered and interactive output missing

2. Calling Python scripts from C/C++ program

3. Calling a python program within a python program

4. HOW TO CALL {Re: How to get output from another rexx script}

5. Losing standard output from called tcl script.

6. accessing calling scripts from called scripts at run time

7. Python CGI output and Apache script log ?

8. Python cgi script - outputting images

9. capturing the output from a called program

10. Input/output in C function called by Fortran Program

11. Newbie question (TCL script calls within C program)

12. Need Help: Calling Tcl/Tk scripts in a C program

 

 
Powered by phpBB® Forum Software