[Twisted-Python] A problem with very long blocking thread in Twisted

Thorne, Stephen stephen at thorne.id.au
Wed Aug 10 11:58:26 EDT 2011

On Wed, Aug 10, 2011 at 15:35, Itamar Turner-Trauring
<itamar at itamarst.org> wrote:
>> To solve this problem, I'd like to set threads as daemon. So that all
>> related threads are terminated when main loop is interrupted. Any idea on
>> this problem will be appreciated.
> I've seen daemon threads causing core dumps on shutdown. Better to either
> use a library that doesn't use threads (which as mentioned is possible in
> this case), or have a timeout on your blocking wait.

When the choice is between aborting a thread and potentially dumping
core, and not exiting, I'll take dumping core.

In order to implement this in twisted, you need to subclass ThreadPool
and override the method that creates the Thread object, or
alternatively, don't use reactor.callInThread(). If you can substitute
a threadpool for txAMPQ then that will probably be the cleanest way.


More information about the Twisted-Python mailing list