Closed stuaxo closed 2 years ago
You can use ipdb.set_trace(cond=first_run)
, it'll only run when first_run
is True
Is first_run a variable I keep track of ?
@stuaxo you create a variable first_run
or whatever you want to name it
cond
checks if a given value is true to stop on breakpoint
Often I'm debugging something that may run several times (it may be some code in a unit test), I want a way to trigger ipdb only on the first time.
At the moment I might do something hacky like this:
But more often I put in a single set_trace(), continue everything with "c" then frantically hit Ctrl-C... (usually "q" doesn't actually quit in unit tests).
So it would be nice to have a proper way of just breaking once, this could be a new API call or maybe passing a parameter to
launch_ipdb_on_exception
.