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..." sleep(15) print
"Done - Nudge,Nudge." foo = FooClass() mythread = threading.Thread(foo.stall()) print 'thread created' mythread.start() print 'thread started' time.sleep(5) print "thread stopped - Wink, Wink" comm1._stop.Set() |
-- http://mail.python.org/mailman/listinfo/python-list