[Chicago] capturing output from subprocesses
bray at sent.com
Tue Nov 8 22:29:16 CET 2005
On Nov 8, 2005, at 2:56 PM, Chris McAvoy wrote:
>> I thought there was a way to manually flush the buffer. I can't
>> think of
>> what it is offhand, though.
> Jiggle the handle.
First, insert Chris's head! :p
Anyway, Jess, this example is really cool. And in Python, great. I
hope you can make it to the meeting.
I thought the subprocess module took care of some of this in 2.4--
although, I have not really checked because usually I only want to
know if it worked or not. I tend to do the same thing with 'C++'
quite often. Basically, you can stream stderr also. And you can set
the buffer size <http://www.cplusplus.com/ref/cstdio/setvbuf.html>.
I am not sure if Threads will help you at all because it sounds like
the process is not that of Python. If it is, Threads are really cool.
They can also be controlled from Python's C API.
One possible work around with capturing errors with Python is to
override the Error handling:
# got this from some other Python forum, can't recall where
# redirects errors to file
def eh(klass, inst, tb):
sys.stderr = file('/tmp/pyerror.log', 'w')
sys.__excepthook__(klass, inst, tb)
sys.stderr = sys.__stderr__
sys.excepthook = eh
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chicago