many_years_after wrote: > Carsten Haese wrote: > > On Sun, 2006-12-24 at 22:55 -0800, many_years_after wrote: > > > Hi, pythoners: > > > > > > There is a problem I couldn't dispose. I start a thread in the my > > > program. The thread will do something before executing time.sleep(). > > > When the user give a signal to the main thread (such as click the 'end' > > > button or close the window), the thread should end it's running. But > > > how to end the threading when it's sleeping? I set an flag to the > > > thread, but it doesn't work. > > > > Is the thread supposed to do some additional work after being woken up? > > If not, there is no point in going to sleep in the first place and the > > thread should just terminate when it has completed its task. If yes, I'd > > use a threading.Event object to .wait() on in the sub-thread rather than > > putting it to sleep, and then .set() the event object in the main thread > > when it's time to wake up the sub-thread. > > > > Hope this helps, > > > > Carsten. > > While , there is something wrong in my expression. What I mean is the > thread will wait some time after doing some tasks. I want to know is > there any method to end the thread or make it out of execution of > waiting. I use time.sleep() to let the thread wait.
So you want a way of stopping a thread while its blocked (waiting) what ever seconds in the time.sleep() method ? > Thanks. If the thread is supposed to do more operation then i would follow what Carsten suggested. Cheers -- http://mail.python.org/mailman/listinfo/python-list