How to "kill" orphaned threads at program exit

Giampaolo Rodola' gnewsg at gmail.com
Mon Dec 29 08:29:58 CET 2008


On 28 Dic, 18:47, Roy Smith <r... at panix.com> wrote:
> In article
> <b133b978-fe63-4893-bb33-8c96bfb59... at v5g2000prm.googlegroups.com>,
>  "Giampaolo Rodola'" <gne... at gmail.com> wrote:
>
> > 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.
>
> You don't say how you're creating your threads, so I'll assume you're using
> threading.Thread().  After creating each thread, and before calling start()
> on it, call setDaemon(True).

Apparently it doesn't make any difference.
A curious thing is that by putting a "print 1" as last instruction the
pending threads get killed and the program exits (Windows XP sp3 32
bit).


--- Giampaolo
http://code.google.com/p/pyftpdlib/



More information about the Python-list mailing list