passing threading.Thread() and function object

Cliff Wells clifford.wells at comcast.net
Wed Oct 13 14:26:55 EDT 2004


On Wed, 2004-10-13 at 13:17 -0500, Christopher J. Bottaro wrote:
> Hello,
> 
> I'm new to Python programming, so please excuse me.
> 
> thread = threading.Thread(self.somefunc())

thread = threading.Thread(target = self.somefunc)

> thread.start()
> print "Thread started"
> 
> def somefunc(self):
>         while (1)
>                 print "In thread"


You are *calling* self.somefunc in your instantiation.  You need to pass
a reference to the method instead.

Regards,
Cliff

-- 
Cliff Wells <clifford.wells at comcast.net>




More information about the Python-list mailing list