Why does bufsize=1 not work in subprocess.Popen ?
- From: "I. Myself" <No.Spam@xxxxxxxxx>
- Date: Sat, 29 Apr 2006 21:44:21 GMT
I read in the docs that "bufsize=1" causes line buffering. (for subprocess.Popen)
The following tiny program launches an executable file and then receives its output. That works, but I want to
receive each line as it is ouput, not all of the lines at termination, which is what is happening.
-------------------------------------------------------
from subprocess import Popen, PIPE
from os import remove, sep
p = Popen("." + sep + "myprogram", stdout=PIPE, bufsize=1)
while(1):
line = p.stdout.readline() # get next line
print line,
if line.count("terminator"):
break
------------------------------------------------------
How can I get line buffering?
Mitchell Timin
--
I'm proud of http://ANNEvolve.sourceforge.net. If you want to write software,
or articles, or do testing or research for ANNEvolve, let me know.
Humans may know that my email address is: (but remove the 3 digit number)
zenguy at shaw666 dot ca
.
- Follow-Ups:
- Re: Why does bufsize=1 not work in subprocess.Popen ?
- From: Marc 'BlackJack' Rintsch
- Re: Why does bufsize=1 not work in subprocess.Popen ?
- Prev by Date: Re: Using Databases in Python
- Next by Date: Re: Need help removing list elements.
- Previous by thread: Can we create an_object = object() and add attribute like for a class?
- Next by thread: Re: Why does bufsize=1 not work in subprocess.Popen ?
- Index(es):
Relevant Pages
|