Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a running python process

Is there a way to see a stacktrace of what various threads are doing inside a python process?

Let's suppose I have a thread which allows me some sort of remote access to the process.

like image 574
Kozyarchuk Avatar asked Apr 02 '09 01:04

Kozyarchuk


People also ask

How do I run and debug Python?

Basic debugging If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on the editor and select Debug Python File in Terminal.

Can I debug Python in idle?

To do so, select Debug → Debugger from the Python IDLE menu bar. In the interpreter, you should see [DEBUG ON] appear just before the prompt ( >>> ), which means the interpreter is ready and waiting. In this window, you can inspect the values of your local and global variables as your code executes.

How do I debug a Python program in Windows?

In any case, right-click the appropriate file and select Set as Startup File. The debugger always starts with the active Python environment for the project. To change the environment, make a different one active as described on Select a Python environment for a project.


2 Answers

Winpdb is a platform independent graphical GPL Python debugger with support for remote debugging over a network, multiple threads, namespace modification, embedded debugging, encrypted communication and is up to 20 times faster than pdb.

Features:

  • GPL license. Winpdb is Free Software.
  • Compatible with CPython 2.3 through 2.6 and Python 3000
  • Compatible with wxPython 2.6 through 2.8
  • Platform independent, and tested on Ubuntu Gutsy and Windows XP.
  • User Interfaces: rpdb2 is console based, while winpdb requires wxPython 2.6 or later.

Screenshot
(source: winpdb.org)

like image 61
nosklo Avatar answered Sep 24 '22 20:09

nosklo


About 4 years ago, when I was using twisted, manhole was a great way to do what you're asking.

http://twistedmatrix.com/projects/core/documentation/howto/telnet.html

Right now most of my projects don't use twisted, so I just WingIDE's remote debugging hooks to introspect a running process.

http://www.wingware.com/doc/debug/remote-debugging

like image 45
Trey Stout Avatar answered Sep 23 '22 20:09

Trey Stout