Grant Edwards wrote:
On 2005-03-01, Steve Horsley <[EMAIL PROTECTED]> wrote:

I am trying to start two threads to do some time consuming work. This is my
first stab at threading, and it isn't working as I expect. Instead of the threads starting when I call start(), they seem to run the target code as
part of the constructor call.


Here is my test code...

#!/usr/bin/python

import time
import threading

def fiddle():
   for n in range(3):
       print n
       time.sleep(1)

print 'Creating threads...'
t1 = threading.Thread(target=fiddle())
t2 = threading.Thread(target=fiddle())


t1 = threading.Thread(target=fiddle)
t2 = threading.Thread(target=fiddle)


Doh! Slap that forehead!

Of course, I was calling fiddle() and using the
return value (None) as the target argument. And
a Thread with a target of None does nothing
when start()ed.

Many thanks.
Steve
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to