Skip to content

debugpy gets "stuck" while using run by line in vscode jupyter notebook #1051

Closed
@roblourens

Description

@roblourens

Before creating a new issue, please check the FAQ to see if your question is answered there.

Environment data

  • debugpy version: 1.6.3
  • OS and version: macOS
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.5
  • Using VS Code or Visual Studio: VS Code

I am working on the "run by line" feature with a jupyter notebook in vscode. There is an issue which I don't think is new. I am just clicking the "run by line" button very quickly, which starts a debug session and sends a "stepIn" request. After trying this a few times, the debugger eventually stops responding.

Basically at this point, the cell finished execution and so we have sent a "disconnect" request to debugpy, but we never get a response. The log from the extension's side shows that as I keep clicking the button to step, vscode sends "stepIn" requests that don't get a response. Here are the debugpy + vscode-jupyter logs from this point where the debugger is not responding.

debugpy.adapter-93501.log
debugpy.pydevd.93407.log
debugpy.server-93407.log
vscodejupyter.log

But there is a workaround: if the user clicks the stop button, we execute the code pass, and this seems to unstick the debugger. We added this workaround in microsoft/vscode-jupyter#7612, although I'm not sure where it came from. Once that happens, we get responses to all the requests that previously weren't getting responses, and can start another debug session if desired. Here are the logs from after executing this workaround (includes the full log of the above, then more)

vscodejupyter.log
debugpy.adapter-93501.log
debugpy.pydevd.93407.log
debugpy.server-93407.log

Can you help me understand what's going on? We try to keep things consistent on the extension's end when stopping/starting new sessions quickly. It's possible that the requests we sent are in a weird order. One thing I have noticed is that when this happens, I see an evaluate request that we sent for variables right before the final disconnect request. If the disconnect request goes out after we got a response for evaluate, then it seems like the issue doesn't happen. I don't know whether that is part of the problem or not. But in any case, it definitely seems like the kernel/debugger is in a broken state.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions