Catching the print
In Linux I currently use the nohub program. $ nohub ./start & to start Zope. That's good, and in nohub.out I get the messages Zope throws. However, when I sometimes use print "I am here" in External Methods or products, that is also printed to stdout, but not into the nohub. Why?? How do I catch the print messages too? And on windows?
Peter Bengtsson writes:
In Linux I currently use the nohub program.
$ nohub ./start &
to start Zope. That's good, and in nohub.out I get the messages Zope throws. However, when I sometimes use print "I am here"
in External Methods or products, that is also printed to stdout, but not into the nohub. Why?? It is printed into "nohup.out", but "nohup.out" is buffered. You will see it only when the buffer is full or explicitely flushed.
Add: from sys import stdout stdout.flush() after your print statement and you will see the output immediately in "nohup.out".
How do I catch the print messages too? And on windows? Even Windows supports redirection of "stdout". Apparently, it stole (and that has been good!) the Unix syntax: "> xxx". We all like that our software incorporates good ideas from others, don't we?
Dieter
Peter Bengtsson writes:
In Linux I currently use the nohub program.
$ nohub ./start &
Add:
from sys import stdout stdout.flush()
after your print statement and you will see the output immediately in "nohup.out".
Thank you very much! It works good. However, I'll have to do this stdout python business each time I want to print something?
Peter Bengtsson writes:
.... from sys import stdout stdout.flush() ....
It works good. However, I'll have to do this stdout python business each time I want to print something? Impatient people have to pay a price :-)
I think, I remember that "python" has an argument and an environ variable that tell Python to keep "stdout" unbuffered even if it is not a terminal. Call "python -h" to see its options. Dieter
participants (2)
-
Dieter Maurer -
Peter Bengtsson