Oops, you probably want to do this then-
for i in range( 0, 3 ):
oThread = Thread( target=mainFunction ).start()
while oThread:
print 'sleeping 3 seconds'
time.sleep( 3 )
A if <condition> generally has an implicit else: pass clause as I
think of it, so it will just keep reiterating if the condition isn't
met.
To see what I mean try -
for i in range(5):
#The 0 is default starting for range function
if i==15:
print 'fifteen'
print i
You'll, of course, get
0
1
2
3
4
It won't wait until i equals 15.
on the other hand -
for i in range(5):
while i != 15:
print "nope"
print i
You'll get a runaway while, and 'nope' will cascade down your stream,
and you'll have great trouble closing Python. But i will never get
printed, as it will still be waiting for i to equal fifteen.
On Tue, 15 Feb 2005 21:54:04 -0500, Bernard Lebel
<[EMAIL PROTECTED]> wrote:
> That is an attempt to catch the death of the thread. I guess I'm not
> taking the right steps ;-)
>
>
> Bernard
>
>
> Liam Clarke wrote:
> > I'm sorry, but when does oThread get the value 1?
> >
> > If you're testing for it's existence via a True/False thing, try
> >
> > if oThread:
> >
> > But otherwise, I'm not sure what you're expecting to get.
> >
> >
> > On Tue, 15 Feb 2005 20:58:15 -0500, Bernard Lebel
> > <[EMAIL PROTECTED]> wrote:
> >
> >>Hello,
> >>
> >>I have already messed a little with simple thread programming, wich took
> >>this form:
> >>
> >>from threading import Thread
> >>
> >>def mainFunction():
> >> pass
> >>
> >>Thread( target=mainFunction ).start()
> >>
> >>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.
> >>
> >>Thanks in advance
> >>Bernard
>
> _______________________________________________
> Tutor maillist - [email protected]
> http://mail.python.org/mailman/listinfo/tutor
>
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor