No output from threads

Larry Whitley ldw at us.ibm.com
Thu Apr 4 09:53:00 EST 2002


On a windows 2k system I have a single master thread, spawning two worker
threads and ending. The master thread is started from the command prompt
(run.py) and the worker threads use "start /belownormal /wait ..." to run a
sequence of C++ programs that I have writen that take a long time to execute
(they're simulation performance models). The start commands have this form:
"start /belownormal /wait myprog.exe -option 3.0 >out3.txt". The two
threads, one for each processor, will work their way through a queue or work
provided by the master thread when the worker threads started.

Unfortunately, while the programs appear to run, at completion their output
files are empty. The files exist but contain no data as a result of the run.
When I run the same program in a non-threaded fashion from a batch file
(without the start statement) I get output in the output files.  In this
case the command looks like this "myprog.exe -optoin 3.0 >out3.txt".

My workstation (windows 2k pro) has two processors so I'd like to use
python's threading to let me run two of my simulations at the same time.
But, I would also like output from the runs.  :-)   Here's the code that
starts the C++ jobs.  It's called by the run() method in the
MyThread(threading.Thread) class.  self.prt() is just adds a thread safe
wrapper around the normal python print command.

    def runJob(self, job):
        command = "start /belownormal /wait "
        command += job[0] + " " # program
        command += job[1] + " " # options
        command += ">" + job[2] # outfile
        self.prt( self.getName() + " is starting " + command )
        os.system( command ) # submit the command to the system



Larry

PS: My reason for using the start command is to let me set the priority of
the jobs to something less than normal.  That way I can continue to use the
workstation without undue delays while the simulations run.






More information about the Python-list mailing list