Stopping all threads from other thread

Bryan Olson fakeaddress at nowhere.org
Sun Aug 20 01:10:04 EDT 2006


amadeusz.jasak at gmail.com wrote:
> Hello,
> it is possible to stop all threads (application) from thread of
> application:
> App
>  |-MainThread
>  |-WebServer
>  |-CmdListener # From this I want to stop App
>  
> The sys.exit isn't working...

You can start all threads other than CmdListener as daemon
threads, using threading.Thread.setDaemon(). Then when
CmdListener exits, the program will exit. Python starts with
one, non-daemon thread, and if that's what you are using for
MainThread, you'd have to switch which thread runs what.

Python deliberately does not offer a threadicide method.


-- 
--Bryan



More information about the Python-list mailing list