Apparently, I don't understand threading

Dave Brueck dave at pythonapocrypha.com
Mon Mar 14 03:19:17 CET 2005


jwsacksteder at ramprecision.com wrote:
> The following script does not behave as expected. I wanted to terminate 
> the 'mythread' thread after 5 seconds.
> 
> What I see is the threading.Thread call blocking until the 15 second 
> sleep is done. Suggestions?
[snip]
> foo = FooClass()
> mythread = threading.Thread(foo.stall())

I think you meant to write:

mythread = threading.Thread(target=foo.stall)

In the original version, you're _calling_ foo.stall at the time of thread creation.

-Dave



More information about the Python-list mailing list