using print() with multiprocessing and pythonw

Isaac Gerg isaac.gerg at gergltd.com
Tue Nov 12 14:12:37 EST 2013


I launch my program with pythonw and begin it with the code below so that all my print()'s go to the log file specified. 

if sys.executable.find('pythonw') >=0:
        # Redirect all console output to file.
        sys.stdout = open("pythonw - stdout stderr.log",'w')
        sys.stderr = sys.stdout

During the course of my program, I call multiprocessing.Process() and launch a function several times.  That function has print()'s inside (which are from warnings being printed by python).  This printing causes the multiprocess to crash.  How can I fix my code so that the print()'s are supressed. I would hate to do a warnings.filterwarnings('ignore') because when I unit test those functions, the warnings dont appear.

Thanks in advance,
Isaac



More information about the Python-list mailing list