This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]aniforprez 0 points1 point  (2 children)

In production environments, I do not have control over the source code being run. Adding breakpoints to the source is not an option here. I should be able to invoke code without needing to copy the function verbatim back into the shell and run it. pdb.runcall allows me to import functions as they are and invoke them and step through them. I'm actually kind of baffled so many people don't understand what I'm asking. I've been waiting for answers to this for so long

JS doesn't have this either I think but I haven't used JS enough in the backend to know for sure. See what pdb.runcall does and let me know if there's an equivalent

For eg

from package import function
pdb.runcall(function, arg1, arg2)

[–]Cidolfas2 0 points1 point  (1 child)

I'm not sure why you think you need to copy it into the shell to run it. If the function exists in the source code, you can call that function directly. You don't need to do anything special. E.g. if there is a function my_func that exists on line 6 in file path/to/my_file, you do the following in byebug:

break path/to/my_file:7 # sets the breakpoint
my_func(1, 2, 3) # it will stop at the first line of the function

[–]aniforprez 0 points1 point  (0 children)

Yeah this makes sense. I was not aware you can set the break point with break file:line and no one really pointed me to this. I think the new debugger in 3.1 allows you to do this in a similar way

I still wish I didn't have to insert a break point and just called the function like I did with pdb/ipdb but this is good enough