microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 293 forks source link

Can't debug an infinite loop using run-by-line (can't interrupt kernel after disconnecting run-by-line debugger) #11187

Closed r3m0t closed 2 years ago

r3m0t commented 2 years ago

Applies To

What happened?

Created a cell with infinite loop

def f():
    i = 0
    while i < float('inf'):
        i+= 1

Add a breakpoint to the first cell

Created another cell which calls into that cell

print(f())

Debug the second cell

You are now debugging and able to step through. Debug toolbar is visible.

The debug toolbar doesn't show the stop icon, only disconnect.

If you disconnect then the cell just executes forever, debug toolbar disappears and the Interrupt button is disabled. Only option left is restarting the kernel in the notebook toolbar.

As for the restart button in the debug toolbar, it does something but I have no idea what. I think it's disconnecting and then reconnecting the debug session, but the code has just kept executing.

VS Code Version

Version: 1.70.2 (user setup) Commit: e4503b30fc78200f846c62cf8091b76ff5547662 Date: 2022-08-16T05:35:13.448Z Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Windows_NT x64 10.0.19044

Jupyter Extension Version

Name: Jupyter Id: ms-toolsai.jupyter Description: Jupyter notebook support, interactive programming and computing that supports Intellisense, debugging and more. Version: 2022.8.1002381050 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter

Jupyter logs

info 11:0:49.974: Preferred Remote kernel for Untitled-2.ipynb is 84780a7b-f172-4a42-8e2c-4a0283e1c481
info 11:0:49.977: Preferred Remote kernel for Untitled-2.ipynb is 84780a7b-f172-4a42-8e2c-4a0283e1c481
info 11:0:49.978: Find preferred kernel for Untitled-2.ipynb with metadata {"orig_nbformat":4,"language_info":{"name":"python"}} & preferred interpreter c:\Users\ther3\anaconda3\python.exe
info 11:0:49.978: Preferred Remote kernel for Untitled-2.ipynb is 84780a7b-f172-4a42-8e2c-4a0283e1c481
info 11:0:49.978: Preferred kernel .jvsc74a57bd0b1236546e0e986a81d69bdaf954501950abdf200e5f55fe90858106a5f64d1a1.c:\Users\ther3\anaconda3\python.exe.c:\Users\ther3\anaconda3\python.exe.-m#ipykernel_launcher is exact match or top match for non python kernels, (true, [object Object], false, false)
info 11:0:49.978: PreferredConnection: .jvsc74a57bd0b1236546e0e986a81d69bdaf954501950abdf200e5f55fe90858106a5f64d1a1.c:\Users\ther3\anaconda3\python.exe.c:\Users\ther3\anaconda3\python.exe.-m#ipykernel_launcher found for NotebookDocument: Untitled-2.ipynb
error 11:0:52.164: Live Notebook not available for Untitled-2.ipynb
error 11:0:52.577: Live Notebook not available for Untitled-2.ipynb
error 11:0:53.615: Live Notebook not available for Untitled-2.ipynb
error 11:0:54.387: Live Notebook not available for Untitled-2.ipynb
error 11:0:54.722: Live Notebook not available for Untitled-2.ipynb
error 11:0:55.138: Live Notebook not available for Untitled-2.ipynb
error 11:0:55.957: Live Notebook not available for Untitled-2.ipynb
error 11:0:56.790: Live Notebook not available for Untitled-2.ipynb
error 11:0:57.219: Live Notebook not available for Untitled-2.ipynb
error 11:0:58.34: Live Notebook not available for Untitled-2.ipynb
info 11:1:0.707: Execute Cell 0 Untitled-2.ipynb
info 11:1:0.708: Starting Jupyter Session id = 'startUsingPythonInterpreter:.jvsc74a57bd0b1236546e0e986a81d69bdaf954501950abdf200e5f55fe90858106a5f64d1a1.c:\Users\ther3\anaconda3\python.exe.c:\Users\ther3\anaconda3\python.exe.-m#ipykernel_launcher' (Python Path: c:\Users\ther3\anaconda3, EnvType: Conda, EnvName: 'base', Version: 3.9.12) for 'Untitled-2.ipynb' (disableUI=false)
info 11:1:0.708: Creating raw notebook for resource 'Untitled-2.ipynb'
info 11:1:0.708: Computing working directory for resource 'Untitled-2.ipynb'
info 11:1:0.710: Starting raw kernel 'base (Python 3.9.12)' for interpreter c:\Users\ther3\anaconda3\python.exe
info 11:1:0.734: Process Execution: > ~\anaconda3\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~\anaconda3\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 11:1:0.975: Kernel launching with ports 9014,9015,9016,9017,9018. Start port is 9000
info 11:1:1.10: Process Execution: > ~\anaconda3\python.exe -m pip list
> ~\anaconda3\python.exe -m pip list
info 11:1:1.41: Adding env Variable PYTHONNOUSERSITE to c:\Users\ther3\anaconda3\python.exe
info 11:1:1.54: Process Execution: > ~\anaconda3\python.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9017 --control=9015 --hb=9014 --Session.signature_scheme="hmac-sha256" --Session.key=b"5cf79b7b-8b06-4a20-9fa2-7e981e175fdf" --shell=9016 --transport="tcp" --iopub=9018 --f=c:\Users\ther3\AppData\Roaming\jupyter\runtime\kernel-v2-34296PCgsgH7eLrtT.json
> ~\anaconda3\python.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9017 --control=9015 --hb=9014 --Session.signature_scheme="hmac-sha256" --Session.key=b"5cf79b7b-8b06-4a20-9fa2-7e981e175fdf" --shell=9016 --transport="tcp" --iopub=9018 --f=c:\Users\ther3\AppData\Roaming\jupyter\runtime\kernel-v2-34296PCgsgH7eLrtT.json
info 11:1:1.54: Process Execution: cwd: ~\dev\somets
cwd: ~\dev\somets
info 11:1:1.342: ipykernel version 6.9.1 for c:\Users\ther3\anaconda3\python.exe
info 11:1:1.342: ipykernel location ~\anaconda3\lib\site-packages\ipykernel\__init__.py for c:\Users\ther3\anaconda3\python.exe
info 11:1:1.601: Widget Message: Received IPyWidgetMessages.IPyWidgets_IsReadyRequest
error 11:1:1.950: Live Notebook not available for Untitled-2.ipynb
error 11:1:2.674: Live Notebook not available for Untitled-2.ipynb
warn 11:1:4.133: StdErr from Kernel Process c:\Users\ther3\anaconda3\lib\site-packages\traitlets\traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  warn(

warn 11:1:4.133: StdErr from Kernel Process c:\Users\ther3\anaconda3\lib\site-packages\traitlets\traitlets.py:2157: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '5cf79b7b-8b06-4a20-9fa2-7e981e175fdf' instead of 'b"5cf79b7b-8b06-4a20-9fa2-7e981e175fdf"'.
  warn(

info 11:1:4.246: Kernel Output: NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see https://github.com/ipython/ipython/issues/2049

To connect another client to this kernel, use:
    --existing c:\Users\ther3\AppData\Roaming\jupyter\runtime\kernel-v2-34296PCgsgH7eLrtT.json

info 11:1:4.376: Started kernel base (Python 3.9.12)., (Raw session started and connected)
info 11:1:4.376: Finished connecting 4168d693-d9bc-469d-b33c-ded4074e3617
error 11:1:4.417: stat() failed for "untitled:Untitled-2.ipynb?jupyter-notebook" [Error (FileSystemError): Unable to resolve filesystem provider with relative file path 'untitled:Untitled-2.ipynb?jupyter-notebook'
    at Function._handleError (c:\Users\ther3\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:87:30174)
    at Object.stat (c:\Users\ther3\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:87:28102)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async b.exists (c:\Users\ther3\.vscode\extensions\ms-toolsai.jupyter-2022.8.1002381050\out\extension.node.js:7:20271)
    at async y.getCode (c:\Users\ther3\.vscode\extensions\ms-toolsai.jupyter-2022.8.1002381050\out\extension.node.js:2:2285764)
    at async Promise.all (index 1)
    at async t.Kernel.gatherInternalStartupCode (c:\Users\ther3\.vscode\extensions\ms-toolsai.jupyter-2022.8.1002381050\out\extension.node.js:2:2250440)
    at async t.Kernel.initializeAfterStart (c:\Users\ther3\.vscode\extensions\ms-toolsai.jupyter-2022.8.1002381050\out\extension.node.js:2:2249025)
    at async t.Kernel.createJupyterSession (c:\Users\ther3\.vscode\extensions\ms-toolsai.jupyter-2022.8.1002381050\out\extension.node.js:2:2246430)
    at async t.Kernel.start (c:\Users\ther3\.vscode\extensions\ms-toolsai.jupyter-2022.8.1002381050\out\extension.node.js:2:2241145)
    at async Function.wrapKernelMethodImpl (c:\Users\ther3\.vscode\extensions\ms-toolsai.jupyter-2022.8.1002381050\out\extension.node.js:2:2492201)] {
  code: 'Unknown'
}
info 11:1:4.418: Executing silently Code (busy) = import os as __VSCODE_os\n__VSCODE_os.environ["PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING"] = "1"\ndel __VSCO
info 11:1:4.638: Executing silently Code (completed) = import os as __VSCODE_os\n__VSCODE_os.environ["PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING"] = "1"\ndel __VSCO with 0 output(s)
info 11:1:4.639: Waiting for idle on (kernel): bd696c95-2398-478d-95f2-2a690b5cdf3d -> idle
info 11:1:4.639: Finished waiting for idle on (kernel): bd696c95-2398-478d-95f2-2a690b5cdf3d -> idle
info 11:1:4.654: Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
info 11:1:4.657: Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
info 11:1:4.659: Widget Message: data-base-url set to https://file%2B.vscode-resource.vscode-cdn.net/c%3A/Users/ther3/.vscode/extensions/ms-toolsai.jupyter-2022.8.1002381050/tmp/scripts/7a44a24b870badaf3d686b431bc6fd244e381147c255049d04043eb3b8c5a4d5/jupyter
info 11:1:4.672: Cell 0 executed with state Success
info 11:1:12.258: Executing silently Code (idle) = import ipykernel\nprint(ipykernel.__version__)
info 11:1:12.274: Executing silently Code (completed) = import ipykernel\nprint(ipykernel.__version__) with 1 output(s)
info 11:1:13.728: Executing silently Code (idle) = import debugpy\ndebugpy.debug_this_thread()
info 11:1:13.798: Executing silently Code (completed) = import debugpy\ndebugpy.debug_this_thread() with 0 output(s)
info 11:1:13.889: Execute Cell 1 Untitled-2.ipynb
info 11:1:26.774: Executing silently Code (idle) = import os\n_VSCODE_fileList = ["C:\\Users\\ther3\\AppData\\Local\\Temp\\ipykernel_16116\\1016497865.p

Coding Language and Runtime Version

conda, python 3.9

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

roblourens commented 2 years ago

I'll have to look into why that toolbar button is disabled. It seems that the stop button on the cell (where the run button normally is) is enabled and works fine when debugging.

GF-Huang commented 2 years ago

Same issue, after disconnect debug, interrupt button disabled, I can't interrupt it.

roblourens commented 2 years ago

Seems fixed now