passing threading.Thread() and function object
zanesdad at bellsouth.net
Wed Oct 13 20:30:22 CEST 2004
Christopher J. Bottaro wrote:
>I'm new to Python programming, so please excuse me.
>thread = threading.Thread(self.somefunc())
>print "Thread started"
> while (1)
> print "In thread"
>"Thread started" never gets printed, but "In thread" gets printed
>repeatedly. What is going on? It seems like thread.start() is blocking
>and effectively running self.somefunc() as a normal function.
>Thanks for the help.
Your code is evaluating self.somefunc(), which is an infinite loop. The
thread is actually never starting. You may want to do something more
print "In thread"
if __name__ == "__main__":
ds = DoSomething()
print "Thread started"
More information about the Python-list