On Tue, 17 Aug 2004 23:18:59 -0400, Jp Calderone <exarkun@divmod.com> wrote:
twisted-10152003@atlas.lcs.mit.edu wrote:
Ah, but that doesn't work. As I stated the c library (not mine) calls potentially block forever (or at least longer than I want to wait to shutdown the twisted server). The thread created by deferTothread may never complete which makes shutting down the server gracefully impossible (or so I thought?).
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.
Perhaps this should be parameterizable (defaulting to the current behavior, of course), so that poorly behaved libraries can be dealt with?
Alternatively, since daemonized threads might lead to this anyway, perhaps you should just add a shutdown event os.kill(os.getpid(), 9) <wwinkink>.
Well, since he only wants to murder the thread at shutdown, a regular "thread killing" API isn't necessary, just a way to have the thread not block shutting down, by dying. Your os.kill suggestion is along the lines of what I was thinking of, except maybe there's a less horrible option :) -- Twisted | Christopher Armstrong: International Man of Twistery Radix | Release Manager, Twisted Project ---------+ http://radix.twistedmatrix.com