Re: Traceback of hanged process
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. In python2.5, you can run a background thread that listens on a port or unix socket, and prints a formatted version of sys._current_frames() to stderr. -Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Traceback of hanged process
Klaas wrote: 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. ... In python2.5, you can run a background thread that listens on a port or unix socket, and prints a formatted version of sys._current_frames() to stderr. You can also use the signal module to similar effect. Works well in Twisted, at least: http://blog.vrplumber.com/835 HTH, Mike -- Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Traceback of hanged process
On 6 ene, 19:45, Hynek Hanke [EMAIL PROTECTED] wrote: 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. On Windows, Pythonwin has an option Break into running code. Try starting the script with python -i, and send it a signal.. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Traceback of hanged process
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Traceback of hanged process
Heh, I kinda messed up the code there. It should be: import sys log_file = open('errors.log', 'w') sys.stderr = log_file your code log_file.close() As for the Ctrl-C, you can catch that when KeyboardInterrupt exception is raised. - Jonathan -- http://mail.python.org/mailman/listinfo/python-list