stoppable child thread

Gabriel Genellina gagsl-py at yahoo.com.ar
Fri Dec 22 15:47:15 EST 2006


james_w77 at yahoo.com ha escrito:

> def main():
>     threads = []
>     try:
>         for i in range(5):
>             t = StoppableThread()
>             t.start()
>             sleep(0.001)
>             threads.append(t)
>
>
>     except KeyboardInterrupt:
>         for t in threads:
>             t.stop()
>             t.join()
>         del threads[:]
>         print 'child thread exiting...'+'/n/n'

Put a print statement just at the end of main() and see what happens.
You said:

> What I want to do is to start 5 child threads, then do something, then
> when got ^C keyboard exception, stop the child thread.

You've created the threads, you've handled ^C, what's missing...?

-- 
Gabriel Genellina




More information about the Python-list mailing list