This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients Void2258, josh.r
Date 2018-03-16.19:38:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521229107.65.0.467229070634.issue33087@psf.upfronthosting.co.za>
In-reply-to
Content
To my knowledge, there is no safe way to do this for other threads for a reason.

If you make all your worker threads daemons, then they will terminate with the main thread, but they won't perform cleanup actions.

If you don't make them daemons, any "clean exit" procedure risks the threads choosing not to exit (even if you inject a SystemExit into every other thread, they might be in a try/except: or try/finally that suppresses it, or blocks waiting for something from another thread that has already exited, etc.). Exiting the thread that calls sys.exit() this way is considered okay, since you control when it is called, and it's up to you to do it at a safe place, but doing so asynchronously in other threads introduces all sorts of problems.

Basically, you want a reliable "shut down the process" and a reliable "clean up every thread", but anything that allows clean up in arbitrary threads also allows them to block your desired "shut down the process". Do you have a proposal for handling this?
History
Date User Action Args
2018-03-16 19:38:27josh.rsetrecipients: + josh.r, Void2258
2018-03-16 19:38:27josh.rsetmessageid: <1521229107.65.0.467229070634.issue33087@psf.upfronthosting.co.za>
2018-03-16 19:38:27josh.rlinkissue33087 messages
2018-03-16 19:38:27josh.rcreate