I am trying to build a browser-based debugging tool for Python but I am having trouble combining the Python inner workings with user interactions. My setup looks like this (jsfiddle link). Essentially I am using sys.settrace
to inspect a function one opcode at a time. My goal is for the user to be able to manually step forward each instruction by pressing the Step
button.
The problems I am having is that the tracer function cannot be asynchronous because Python does not like that, and if it is synchronous there is no real way to stop and wait for input/interaction. If I make just an infinite while loop it freezes the browsers main thread so the page becomes unresponsive.
Does anyone have advice on how I can structure this to allow interaction between the UI and the tracer function?