That’s a good question and would be interested if anyone knows the answer. I used do this a lot with gdb and C++ server code
Now that I think about it I bet you could attach pdb to a process running the python interpreter and find your way to the right level of abstraction. Does not sound practical though