On Sat, Sep 17, 2011 at 2:35 PM, Chris Angelico <ros...@gmail.com> wrote: > On Sun, Sep 18, 2011 at 5:00 AM, Nobody <nob...@nowhere.com> wrote: >> The only robust solution is to use a separate process (threads won't >> suffice, as they don't have a .kill() method). > > Forking a thread to discuss threads.... ahem. > > Why is it that threads can't be killed? Do Python threads correspond > to OS-provided threads (eg POSIX threads on Linux)? Every OS threading > library I've seen has some way of killing threads, although I've not > looked in detail into POSIX threads there (there seem to be two > options, pthread_kill and pthread_cancel, that could be used, but I've > not used either). If nothing else, it ought to be possible to > implement a high level kill simply by setting a flag that the > interpreter will inspect every few commands, the same way that > KeyboardInterrupt is checked for. > > Is it just that nobody's implemented it, or is there a good reason for > avoiding offering this sort of thing?
It's possible that the reason is analogous to why Java has deprecated its equivalent, Thread.stop(): http://download.oracle.com/javase/1.4.2/docs/guide/misc/threadPrimitiveDeprecation.html Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list