[Twisted-Python] Re: twisted and threading

glyph at divmod.com glyph at divmod.com
Thu Nov 25 15:43:20 EST 2004

On Thu, 25 Nov 2004 15:24:57 +0000 (UTC), Paul Moore <paul.moore at atosorigin.com> wrote:
>Jp Calderone <exarkun <at> divmod.com> writes:

> >    There is no portable way to terminate a thread without its 
> > assistance.  Python supports no API for this - save one, the 
> > ridiculously named "setDaemon" Thread method.  Twisted doesn't expose 
> > this, nor call it internally, as it can lead to segfaults.

> I have hit the same problem recently (C library calls that might hang, and I 
> want to give up and quit regardless in the end). What I came up with was a 
> function deferToDaemonThread, which put the call in a daemon thread (one that 
> the Python main thread will not wait for). It steals a lot of code from 
> deferToThread, but creates a dedicated daemon thread for the call rather than 
> using the thread pool.

IMHO, if a library is _that_ poorly behaved, you ought to be communicating with it over a socket or pipe.  Anybody up for writing a 'deferToPythonSubprocess'?

More information about the Twisted-Python mailing list