Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to step through debug twisted?

I'd like to be able to debug Punjab, a twisted python application, in Netbeans so that I can step through the code. How can I do that? Alternatively, how could I do it in a different debugger?

like image 891
leeb Avatar asked Mar 23 '10 15:03

leeb


People also ask

How do I create a run/debug configuration for twisted trial tests?

Use this dialog to create a run/debug configuration for Twisted trial tests. Click one of the radio-buttons to choose the possible target.: Module name: by using a Python module name and a test class instance. Script path: by using a path to a Python file. Custom: by using an arbitrary combination of paths, modules, and test class instances.

What is the difference between step over and step out debugging?

If the current line contains a function call, Step Over runs the code and then suspends execution at the first line of code after the called function returns. Step Out continues running code and suspends execution when the current function returns. The debugger skips through the current function.

What are the debugger step commands?

The debugger step commands help you inspect your app state or find out more about its execution flow. To stop on each statement when you're debugging, use Debug > Step Into, or select F11. The debugger steps through code statements, not physical lines. For example, an if clause can be written on one line:

How do you debug a nested function in Python?

On a nested function call, Step Into steps into the most deeply nested function. For example, if you use Step Into on a call like Func1 (Func2 ()), the debugger steps into the function Func2. As you run each line of code, you can hover over variables to see their values, or use the Locals and Watch windows to watch the values change.


1 Answers

Since you're trying to debug a twisted application, you have a few options:

  1. If you're running via twistd you can use the -b command-line options:

       -b, --debug            run the application in the Python Debugger (implies
                              nodaemon), sending SIGUSR2 will drop into debugger
    
  2. You can run manhole in your twisted process - this allows you to telnet into the server and examine Python objects - http://twistedmatrix.com/documents/current/core/howto/telnet.html

  3. You can optionally run pdb manually - see: http://docs.python.org/library/pdb.html

like image 52
rlotun Avatar answered Oct 01 '22 22:10

rlotun