Skip to content
This repository

Allow pausing while running #42

Closed
cool-RR opened this Issue · 5 comments

3 participants

Ram Rachum Andreas Klöckner Aaron Meurer
Ram Rachum

Sometimes I'll be running a program, and then it stalls so bad and I have no idea why.

In my main debugger, I'm able to pause execution by pressing Shift-F5. Then I can see which line the program is stuck on. A similar feature in pudb would help.

Andreas Klöckner
Owner

Ctrl-C should get you into the debugger. You can't resume execution from there, unfortunately, but I don't quite know how to fix that.

Ram Rachum

Okay, that's a workaround that could be useful sometimes. Let's just leave this issue around until someone knows how to fix it.

Aaron Meurer
Collaborator

My trick from #31 (comment) let's you do exactly this. So solving #31 would make solving this issue easy.

Aaron Meurer
Collaborator

OK, as expected, this is trivial to implement. See #63. It doesn't work with set_trace() yet (only starting the script with pudb script.py), but implementing that should be easy as well. I just need to figure out the correct place to put the code.

Aaron Meurer asmeurer referenced this issue from a commit in asmeurer/PuDB
Aaron Meurer asmeurer Fix up some more of the interrupt framework
This (partially) fixes #42, and also improves work on #31.

Now, interrupting with Control-C works when the debugging is started with
set_trace().

The SIGINT handler is enabled via the public function
pudb.set_interrupt_handler.  If you want to be able to enter PuDB from within
your application, just call this function.  By default, it uses SIGINT (i.e.,
Control-C), but you can change it to use a different signal if that one
interferes.

There is still one major issue, which is that when you break in the middle of
an atomic operation, it goes to bdb. After pressing `n` several times you get
to your code, though.
ce06073
Aaron Meurer
Collaborator

See #63 for work on this.

Aaron Meurer asmeurer referenced this issue from a commit in asmeurer/PuDB
Aaron Meurer asmeurer Fix up some more of the interrupt framework
This (partially) fixes #31, and also improves work on #42.

Now, interrupting with Control-C works when the debugging is started with
set_trace().

The SIGINT handler is enabled via the public function
pudb.set_interrupt_handler.  If you want to be able to enter PuDB from within
your application, just call this function.  By default, it uses SIGINT (i.e.,
Control-C), but you can change it to use a different signal if that one
interferes.

There is still one major issue, which is that when you break in the middle of
an atomic operation, it goes to bdb. After pressing `n` several times you get
to your code, though.
3c2d5ae
Aaron Meurer asmeurer closed this issue from a commit
Aaron Meurer asmeurer Enable Control-C to pause the debugger
This fixes #42.  Now pressing Control-C while the script is running enters the
debugger in the line that was run (i.e., it does a set_trace()).

Note that this only works if the script was invoked from `pudb` or `python -m
pudb`.  If PuDB was started with `import pudb; pudb.set_trace()`, this does
not work.  But not that even without this patch, Control-C kills Python
entirely in that case (as opposed to entering post-mortem mode).
8911613
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.