Search code examples
pythonpdb

How to exit pdb and allow program to continue?


I'm using the pdb module to debug a program. I'd like to understand how I can exit pdb and allow the program to continue onward to completion. The program is computationally expensive to run, so I don't want to exit without the script attempting to complete. continue doesn't seems to work. How can I exit pdb and continue with my program?


Solution

  • continue should "Continue execution, only stop when a breakpoint is encountered", so you've got a breakpoint set somewhere. To remove the breakpoint (if you inserted it manually):

    (Pdb) break
    Num Type         Disp Enb   Where
    1   breakpoint   keep yes   at /path/to/test.py:5
    (Pdb) clear 1
    Deleted breakpoint 1
    (Pdb) continue
    

    Or, if you're using pdb.set_trace(), you can try this (although if you're using pdb in more fancy ways, this may break things...)

    (Pdb) pdb.set_trace = lambda: None  # This replaces the set_trace() function!
    (Pdb) continue
    # No more breaks!