How to "kill" orphaned threads at program exit

Giampaolo Rodola' gnewsg at gmail.com
Sun Dec 28 12:33:00 EST 2008


Hi,
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():
    ...
    start_suite()
    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
http://code.google.com/p/pyftpdlib/




More information about the Python-list mailing list