Traceback of hanged process

Jonathan Curran jonc at icicled.net
Sat Jan 6 18:37:20 EST 2007


On Saturday 06 January 2007 16:45, Hynek Hanke wrote:
> Hello,
>
> please, how do I create a pythonic traceback from a python process that
> hangs and is not running in an interpreter that I executed manually
> or it is but doesn't react on CTRL-C etc? I'm trying to debug a server
> implemented in Python, so I need some analog of 'gdb attach' for C.
>
> Unfortunatelly, googling and reading documentation revealed nothing, so
> please excuse if this question is dumb.
>
> Thank you,
> Hynek Hanke

Hynek,
	It is possible to redirect stderr to a file so that in case of a crash or 
fault the errors will be logged to a file. I think the following code would 
do it.

import sys

log_file = open('errors.log', 'w')
sys.stderr = open('errors.log', 'w')

<your code>

log_file.close()

Hope it helps.

- Jonathan



More information about the Python-list mailing list