Apparently, I don't understand threading

jwsacksteder at jwsacksteder at
Sun Mar 13 23:39:27 CET 2005

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?


import threading

from time import sleep


class FooClass:

            def __init__(self):

                        self._stop = threading.Event()


            def stall(self):

                        print self._stop.isSet()

                        while not self._stop.isSet():

                                    print "Please hold..."


                                    print "Done - Nudge,Nudge."


foo = FooClass()

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

print 'thread created'


print 'thread started'


print "thread stopped - Wink, Wink"


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list