[Twisted-Python] 2 threads questions

Jonathan Vanasco twisted-python at 2xlp.com
Wed Mar 28 12:44:23 EDT 2007


On Mar 27, 2007, at 12:30 PM, Jean-Paul Calderone wrote:

>
> 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.


Great!  Thanks.

Still working on debugging this, but for other people who need to  
jump into a manhole for something like this in the future  -- the  
following works well.



=======

import sys
import traceback

def formatTraceback ( frameId , frameObj ):
	traceback_lines= traceback.format_stack( frameObj )
	if not len(traceback_lines):
		return
	print ""
	print  
"----------------------------------------------------------------------- 
-----------"
	print ">> --- %s | %s ===================================" %  
( frameId , frameObj )
	print "".join(traceback_lines)
	print "<< --- %s | %s ===================================" %  
( frameId , frameObj )
	print ""

def printCurrentStack():
	frames= sys._current_frames()
	for frameId in frames:
		frameObj= frames[frameId]
		formatTraceback( frameId , frameObj )

printCurrentStack()








// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -






More information about the Twisted-Python mailing list