[Twisted-Python] 2 threads questions

Jean-Paul Calderone exarkun at divmod.com
Tue Mar 27 10:30:30 MDT 2007


On Tue, 27 Mar 2007 12:03:44 -0400, Jonathan Vanasco <twisted-python at 2xlp.com> wrote:
>i have a threaded daemon which occasionally hangs because of some  stalling 
>in the threadpool
>
>a-      whats the best way to shut it down ?
>         attempts to ctl-c / kill it seem to be interpreted by a random 
>thread.  the only way to kill it is a kill -9
>         the python threading docs said that was the expected behavior, and 
>that it could be avoided by using signal.
>         I figured twisted might have something in it already to handle 
>shutting down a reactor with active threads.  the threads docs for  twisted 
>are a little light.
>
>b-      i'm trying to figure out the cause of the stalling in the threadpool
>         from the status messages i'm printing, I'm seeing the main python 
>code firing fine, but the threadpool is just stuck - nothing  dispatched to 
>it seems to clean up
>         i wonder if it might be related to a few tickets i've seen
>                 http://twistedmatrix.com/trac/ticket/2448
>                 http://trac.edgewall.org/ticket/3923
>
>         i'm trying to figure out a way to reliably test this.  i've got a 
>ssh manhole running via conch ( and instructions from the twisted book )
>         can anyone suggest a good way to test and try to debug what is going 
>on?  i'm extremely uninformed when it comes to python threads.
>

Python 2.5 includes sys._current_frames() which returns a mapping from thread
identifiers to the frame objects which you might be able to use to learn what
is going on.  You can call this from your manhole prompt when you notice the
system to have hung.

Jean-Paul




More information about the Twisted-Python mailing list