[Tutor] Queued threads

Max Noel maxnoel_fr at yahoo.fr
Wed Feb 16 03:30:38 CET 2005


On Feb 16, 2005, at 01:58, Bernard Lebel wrote:

> Now, I have a list of "jobs", each job being a windows bat file that 
> launches an executable and performs a rendering task. So I have this 
> queue of jobs, and would like to launch one only when the previous one 
> has finished, and in a separate window. So far I have not been having 
> much success with simple stuff:
>
>
> from threading import Thread
>
> def mainFunction():
>     print 'function print'
>     return 1
>
> for i in range( 0, 3 ):
>     oThread = Thread( target=mainFunction ).start()
>
>     if oThread == 1:
>             print 'sleeping 3 seconds'
>             time.sleep( 3 )
>
>
> In this example, 'sleeping 3 seconds' not returned, and each thread is 
> started without any waiting.
>
>
> I'm looking at the various threading module details in the library but 
> I have to admit that, well, I'm a bit at loss here.

	Okay, so basically, what you want to do is:

- Start the first bat file.
- Wait for it to finish.
- Start the second bat file.
- Wait for it to finish.
- Start the third bat file.
- Wait for it to finish.

	This just begs the following question: why are you even using threads 
to do that? This is perfectly sequential, with no element of 
simultaneity whatsoever...

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?"



More information about the Tutor mailing list