Stopping all threads from other thread

A

amadeusz.jasak

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...

Amadeusz Jasak (Poland)
 
B

Bryan Olson

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.
 
A

alfanick

Thanks,
it's working

Bryan said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top