How to "kill" orphaned threads at program exit

Giampaolo Rodola' gnewsg at
Sun Dec 28 18:33:00 CET 2008

I know that it's not possible to "kill" threads but I'm wondering if
does exist some workaround for my problem.
I have a test suite which does a massive usage of threads.
Sometimes happens that one test fails, the test suite keeps running
until the end, and when it's finished the program hangs on and the
only way to stop is to kill it manually.
I noticed that, at the end of the program, I can call
threading.enumerate() and see the pending thread objects:

def test_main():
    print threading.enumerate()

I was wondering if I can do anything with that.
I took a look at test/test_support which has threading_setup() and
threading_cleanup() functions.
Could such functions be useful to me?

Thanks in advance,

--- Giampaolo

More information about the Python-list mailing list