[p4] Terminal output in p4v tools
Rick Macdonald
rickmacd at shaw.ca
Mon Nov 12 14:54:08 PST 2007
I don't know Python but I was curious and had a look.
What about starting python with "-u"?
From python -h:
-u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
see man page for details on internal buffering relating to '-u'
From man:
-u Force stdin, stdout and stderr to be totally unbuffered. On
systems where it matters, also put stdin, stdout and stderr in
binary mode. Note that there is internal buffering in xread-
lines(), readlines() and file-object iterators ("for line in
sys.stdin") which is not influenced by this option. To work
around this, you will want to use "sys.stdin.readline()" inside
a "while 1:" loop.
...RickM...
Gross, Steve wrote:
>> I must have found this with Google, because I don't know perl, but this
>>
> works for me:
>
>> my( $oldHandle );
>> # Force a flush on STDOUT
>> $oldHandle = select (STDOUT); # "select" STDOUT and save previously
>>
> selected handle
>
>> $| = 1; # perform flush after each write to
>>
> STDOUT
>
>> select ($oldHandle); # restore previously selected handle
>>
>
> Sounds workable in perl, anyway. I'm using python:
> sys.stdout.write("some message\n")
> sys.stdout.flush()
>
> --Steve
>
>
More information about the perforce-user
mailing list