Feature Request - Stopping on breakpoints from interactive debugger
Note - I hope this feature place is on pdevd and not one of its clients. as I am not sure on the functionalities "border" between them.
Suppose I have the following code
#module run.py
import dummy
from calc import calc
def run():
print('Running calc() function')
y = dummy.perform_very_long_calculation()
out = calc(y) #*** BP1 IS HERE ***
print(out)
run()
#module calc.py
def calc(x):
print('Calculating ...')
# do a lot of staff
# some code to debug and probably FIX SEVERAL TIMES
#*** BP2 IS HERE ***
return answer
The requested work flow is:
- Stop on BP1
- Run calc(y) from the interactive debugger console
- Stop on BP2
- Inspect calc() code and edit it (fix nad even continue develop it)
- Reload module calc for the changes to take effect
- Return to run frame (context) which is still waiting on BP1
- Goto step 2 until I an happy with calc()
Request Rational Sometimes you have to debug piece of code that is so deep and nested that it take time and setup to reach there. You don't want to pay this time for each debugging iterations. For programmers who have ported from Matlab (and probably R, as I read in SO) it became a regular debugging and even interactive developing practice. When porting to Python this feature is really missed.
Of course, one workaround is to pickle calc inputs and write a mock that load them and call calc() but this is extra coding and not very elegant solution (IMHO).
I already asked if this feature exists, in any python IDE, several times on stack overflow here and here and even ask pycharm here (not sure if public) that uses pydevd.
Unfortunately, all the answers were it is not exists.
Humm, if you create an interactive console on PyDev (http://www.pydev.org/manual_adv_interactive_console.html) and attach it to a debug session (see Full Debug Support in Interactive Console in that page), you should be able to hit breakpoints from the interactive session.
You still can't stop in a breakpoint while you're inside a breakpoint, but I think it could handle your needs... no?
Thanks @fabioz. I really appreciate your great work. This not really handle my needs, because i need the first breakpoint for the inputs context and the second breakpoint for the iterative debugging/developing of calc(). I am exactly talking of "stop in a breakpoint while i'm inside a breakpoint" - is it python limitation?
No, that's not a python limitation, it's only a limitation of the implementation of the pydev.debugger (it's not impossible to add that feature, it just needs work to be properly worked on/tested -- and possibly have a choice on whether that feature should be available, as I don't think it's always wanted by users).
I must say my time is currently pretty short and I'm not sure when I'll be able to work on that feature in the near future... choices could be:
-
taking a look at it yourself and provide a pull request (it is open source after all -- in particular, I know we protect against that in the code through an
is_tracingvariable, although that's probably not the only safeguard for that and just turning it off may cause other issues). -
sponsoring the work to implement the feature (if you'd be interested, you can contact me directly through fabiofz at gmail dot com).
Thanks. I will try to look at the code but as I am new to python and guess that debugger touch the deepest layers that even advanced python developers struggle with, I doubt it will work.