sys.stdout redirection

Bala blk at
Mon Jul 19 08:44:41 CEST 2004

    Iam redirecting the sys.stdout to the file. iam doing this is multiple thread.

While running my application exception throws "Value.error I/O Operation on closed file"

I want to know whether, this exception is coming because of  the thread or sys.stdout.

what could be the problem...hove to overcome this problem..

thanks in advance. Kindly give some solution for this problem

import sys

boolStdOut = True
if boolStdOut == 1:
    print "This is stdout"
    oldStd = sys.stdout
    sys.stdout = open("c:\\std.out", "w")
    print "This is Redirected stdout to the file"
    sys.stdout = oldStd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list