Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid message: Session is already started when trying to debug a cell in Jupyter notebook #15694

Closed
1 of 2 tasks
epicwhale opened this issue May 16, 2024 · 3 comments
Closed
1 of 2 tasks
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Issue needs to be triaged

Comments

@epicwhale
Copy link

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

When I try to debug a cell in a notebook, the first cell runs in debug mode, when I run debug for the second cell, I get this error message.

image

VS Code Version

Version: 1.90.0-insider Commit: 0cd8d6ac480bc5b4e2a2d7f1eb87eaff9f7d47e1 Date: 2024-05-16T05:50:49.491Z Electron: 29.3.1 ElectronBuildId: 9464424 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.4.0

Jupyter Extension Version

v2024.4.2024042601 (pre-release)

Jupyter logs

20:44:19.173 [debug] Cell Index:0 sent to kernel
20:44:19.182 [debug] [Debug] to kernel: {"command":"threads","type":"request","seq":18}
20:44:19.182 [debug] [Debug] to kernel, mapped: {"command":"threads","type":"request","seq":18}
20:44:19.183 [debug] Start cell 0 execution @ 1715892259183 (clear output)
20:44:19.183 [debug] Kernel acknowledged execution of cell 0 @ 1715892259183
20:44:19.194 [debug] [Debug] response: {"seq":17,"type":"response","request_seq":18,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":"MainThread"},{"id":2,"name":"Thread-2 (_watch_pipe_fd)"},{"id":3,"name":"Thread-3 (_watch_pipe_fd)"},{"id":4,"name":"IPythonHistorySavingThread"}]}}
20:44:22.047 [debug] [Debug] event: {"header":{"msg_id":"82e43904-24f05d563bcd9dbf0456f18d_37452_109","msg_type":"debug_event","username":"~","session":"82e43904-24f05d563bcd9dbf0456f18d","date":"2024-05-16T20:44:22.046778Z","version":"5.3"},"parent_header":{"date":"2024-05-16T20:44:19.182000Z","msg_id":"1d4814f3-3619-444c-b759-940fb6565c78","msg_type":"debug_request","session":"3e1b4c1c-ab58-4754-84fe-5f1f6fe2d78d","username":"276f8c1f-910f-4ffb-a46d-dc33f5ceb4bb","version":"5.2"},"metadata":{},"content":{"seq":18,"type":"event","event":"thread","body":{"reason":"started","threadId":5}},"idents":[{"type":"Buffer","data":[107,101,114,110,101,108,46,52,97,52,53,50,52,101,100,45,99,55,50,98,45,52,55,56,48,45,97,100,53,48,45,52,100,56,50,51,55,48,57,53,48,99,97,46,100,101,98,117,103,95,101,118,101,110,116]}],"buffers":[],"channel":"iopub"}
20:44:22.109 [info] Cell 0 completed in 2.926s (start: 1715892259183, end: 1715892262109)
20:44:22.109 [debug] Cell 0 executed successfully
20:44:22.121 [info] Ending debug session 08644409-a45d-4483-b177-85997ff37592
20:44:22.164 [debug] [Debug] to kernel: {"command":"threads","type":"request","seq":19}
20:44:22.164 [debug] [Debug] to kernel, mapped: {"command":"threads","type":"request","seq":19}
20:44:22.169 [debug] [Debug] response: {"seq":19,"type":"response","request_seq":19,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":"MainThread"},{"id":2,"name":"Thread-2 (_watch_pipe_fd)"},{"id":3,"name":"Thread-3 (_watch_pipe_fd)"},{"id":4,"name":"IPythonHistorySavingThread"},{"id":5,"name":"asyncio_0"}]}}
20:44:22.195 [info] Skipping sending message request because session is disposed
20:44:22.307 [debug] [Debug] event: {"header":{"msg_id":"82e43904-24f05d563bcd9dbf0456f18d_37452_120","msg_type":"debug_event","username":"~","session":"82e43904-24f05d563bcd9dbf0456f18d","date":"2024-05-16T20:44:22.307164Z","version":"5.3"},"parent_header":{"date":"2024-05-16T20:44:22.164000Z","msg_id":"9d8c9908-3db0-47e3-9f20-89ebeec2921a","msg_type":"debug_request","session":"3e1b4c1c-ab58-4754-84fe-5f1f6fe2d78d","username":"276f8c1f-910f-4ffb-a46d-dc33f5ceb4bb","version":"5.2"},"metadata":{},"content":{"seq":20,"type":"event","event":"thread","body":{"reason":"started","threadId":6}},"idents":[{"type":"Buffer","data":[107,101,114,110,101,108,46,52,97,52,53,50,52,101,100,45,99,55,50,98,45,52,55,56,48,45,97,100,53,48,45,52,100,56,50,51,55,48,57,53,48,99,97,46,100,101,98,117,103,95,101,118,101,110,116]}],"buffers":[],"channel":"iopub"}
20:44:22.310 [info] Execution of code ms-toolsai.jupyter-5 completed in 69ms
20:44:22.313 [debug] [Debug] event: {"header":{"msg_id":"82e43904-24f05d563bcd9dbf0456f18d_37452_124","msg_type":"debug_event","username":"~","session":"82e43904-24f05d563bcd9dbf0456f18d","date":"2024-05-16T20:44:22.312873Z","version":"5.3"},"parent_header":{"date":"2024-05-16T20:44:22.164000Z","msg_id":"9d8c9908-3db0-47e3-9f20-89ebeec2921a","msg_type":"debug_request","session":"3e1b4c1c-ab58-4754-84fe-5f1f6fe2d78d","username":"276f8c1f-910f-4ffb-a46d-dc33f5ceb4bb","version":"5.2"},"metadata":{},"content":{"seq":21,"type":"event","event":"thread","body":{"reason":"exited","threadId":6}},"idents":[{"type":"Buffer","data":[107,101,114,110,101,108,46,52,97,52,53,50,52,101,100,45,99,55,50,98,45,52,55,56,48,45,97,100,53,48,45,52,100,56,50,51,55,48,57,53,48,99,97,46,100,101,98,117,103,95,101,118,101,110,116]}],"buffers":[],"channel":"iopub"}
20:44:22.411 [debug] [Debug] to kernel: {"command":"threads","type":"request","seq":20}
20:44:22.411 [debug] [Debug] to kernel, mapped: {"command":"threads","type":"request","seq":20}
20:44:22.416 [debug] [Debug] response: {"seq":22,"type":"response","request_seq":20,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":"MainThread"},{"id":2,"name":"Thread-2 (_watch_pipe_fd)"},{"id":3,"name":"Thread-3 (_watch_pipe_fd)"},{"id":4,"name":"IPythonHistorySavingThread"},{"id":5,"name":"asyncio_0"}]}}
20:44:23.571 [info] Starting debugging with mode 1
20:44:23.572 [debug] Executing silently Code (idle) = import builtins\nimport ipykernel\nbuiltins.print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d" + ipykernel._
20:44:23.621 [debug] Executing silently Code (completed) = import builtins\nimport ipykernel\nbuiltins.print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d" + ipykernel._ with 1 output(s)
20:44:23.648 [debug] [Debug] to kernel: {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code - Insiders","adapterID":"Python Kernel Debug Adapter","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true,"supportsStartDebuggingRequest":true},"type":"request","seq":1}
20:44:23.648 [debug] [Debug] to kernel, mapped: {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code - Insiders","adapterID":"Python Kernel Debug Adapter","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true,"supportsStartDebuggingRequest":true},"type":"request","seq":1}
20:44:23.653 [debug] [Debug] response: {"seq":23,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDebuggerProperties":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsExceptionInfoRequest":true,"supportsExceptionOptions":true,"supportsFunctionBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsModulesRequest":true,"supportsSetExpression":true,"supportsSetVariable":true,"supportsValueFormattingOptions":true,"supportsTerminateRequest":true,"supportsGotoTargetsRequest":true,"supportsClipboardContext":true,"exceptionBreakpointFilters":[{"filter":"raised","label":"Raised Exceptions","default":false,"description":"Break whenever any exception is raised."},{"filter":"uncaught","label":"Uncaught Exceptions","default":true,"description":"Break when the process is exiting due to unhandled exception."},{"filter":"userUnhandled","label":"User Uncaught Exceptions","default":false,"description":"Break when exception escapes into library code."}],"supportsStepInTargetsRequest":true,"supportsRestartRequest":true}}
20:44:23.698 [debug] [Debug-Reset] attach: Continuing paused kernel threads if needed
20:44:23.707 [debug] [Debug] to kernel: {"command":"debugInfo","type":"request","seq":3}
20:44:23.707 [debug] [Debug] to kernel, mapped: {"command":"debugInfo","type":"request","seq":3}
20:44:23.710 [debug] [Debug] response: {"type":"response","request_seq":3,"success":true,"command":"debugInfo","body":{"isStarted":true,"hashMethod":"Murmur2","hashSeed":3339675911,"tmpFilePrefix":"/tmp/ipykernel_37452/","tmpFileSuffix":".py","breakpoints":[],"stoppedThreads":[],"richRendering":true,"exceptionPaths":["Python Exceptions"],"copyToGlobals":true}}
20:44:23.758 [debug] [Debug] to kernel: {"command":"attach","arguments":{"type":"Python Kernel Debug Adapter","name":"###_###_appt_###_single.ipynb","request":"attach","justMyCode":true,"__mode":1,"__cellIndex":1,"__notebookUri":"file:///workspace/backend/###/###/notebooks/###_###_appt_###_single.ipynb","__sessionId":"45d86fb7-0a72-403a-8694-b07ee9f4d75c"},"type":"request","seq":2}
20:44:23.758 [debug] [Debug] to kernel, mapped: {"command":"attach","arguments":{"type":"Python Kernel Debug Adapter","name":"###_###_appt_###_single.ipynb","request":"attach","justMyCode":true,"__mode":1,"__cellIndex":1,"__notebookUri":"file:///workspace/backend/###/###/notebooks/###_###_appt_###_single.ipynb","__sessionId":"45d86fb7-0a72-403a-8694-b07ee9f4d75c"},"type":"request","seq":2}
20:44:23.763 [debug] [Debug] response: {"seq":24,"type":"response","request_seq":2,"success":false,"command":"attach","message":"Invalid message: Session is already started"}
20:44:23.821 [debug] [Debug] to kernel: {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":4}
20:44:23.821 [debug] [Debug] to kernel, mapped: {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":4}
20:44:23.825 [debug] [Debug] event: {"header":{"msg_id":"82e43904-24f05d563bcd9dbf0456f18d_37452_143","msg_type":"debug_event","username":"~","session":"82e43904-24f05d563bcd9dbf0456f18d","date":"2024-05-16T20:44:23.824919Z","version":"5.3"},"parent_header":{"date":"2024-05-16T20:44:23.821000Z","msg_id":"f4795814-ba78-4d10-8026-0213b7b2a1b8","msg_type":"debug_request","session":"3e1b4c1c-ab58-4754-84fe-5f1f6fe2d78d","username":"276f8c1f-910f-4ffb-a46d-dc33f5ceb4bb","version":"5.2"},"metadata":{},"content":{"seq":25,"type":"event","event":"terminated"},"idents":[{"type":"Buffer","data":[107,101,114,110,101,108,46,52,97,52,53,50,52,101,100,45,99,55,50,98,45,52,55,56,48,45,97,100,53,48,45,52,100,56,50,51,55,48,57,53,48,99,97,46,100,101,98,117,103,95,101,118,101,110,116]}],"buffers":[],"channel":"iopub"}
20:44:23.825 [debug] [Debug] event: {"header":{"msg_id":"82e43904-24f05d563bcd9dbf0456f18d_37452_143","msg_type":"debug_event","username":"~","session":"82e43904-24f05d563bcd9dbf0456f18d","date":"2024-05-16T20:44:23.824919Z","version":"5.3"},"parent_header":{"date":"2024-05-16T20:44:23.821000Z","msg_id":"f4795814-ba78-4d10-8026-0213b7b2a1b8","msg_type":"debug_request","session":"3e1b4c1c-ab58-4754-84fe-5f1f6fe2d78d","username":"276f8c1f-910f-4ffb-a46d-dc33f5ceb4bb","version":"5.2"},"metadata":{},"content":{"seq":25,"type":"event","event":"terminated"},"idents":[{"type":"Buffer","data":[107,101,114,110,101,108,46,52,97,52,53,50,52,101,100,45,99,55,50,98,45,52,55,56,48,45,97,100,53,48,45,52,100,56,50,51,55,48,57,53,48,99,97,46,100,101,98,117,103,95,101,118,101,110,116]}],"buffers":[],"channel":"iopub"}
20:44:23.826 [debug] [Debug] response: {"seq":26,"type":"response","request_seq":4,"success":true,"command":"disconnect"}
20:44:23.911 [debug] [Debug] to kernel: {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":21}
20:44:23.911 [debug] [Debug] to kernel, mapped: {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":21}
20:44:23.915 [debug] KernelProcess error 37452: [IPKernelApp] ERROR | Exception in control handler:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 362, in process_control
    await result
  File "/usr/local/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 1039, in debug_request
    reply_content = await reply_content
                    ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ipykernel/ipkernel.py", line 528, in do_debug_request
    return await self.debugger.process_request(msg)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ipykernel/debugger.py", line 740, in process_request
    self.stop()
  File "/usr/local/lib/python3.12/site-packages/ipykernel/debugger.py", line 445, in stop
    self.debugpy_client.disconnect_tcp_socket()
  File "/usr/local/lib/python3.12/site-packages/ipykernel/debugger.py", line 280, in disconnect_tcp_socket
    self.debugpy_stream.socket.disconnect(self._get_endpoint())
  File "zmq/backend/cython/socket.pyx", line 664, in zmq.backend.cython.socket.Socket.disconnect
zmq.error.ZMQError: No such file or directory

Coding Language and Runtime Version

Python 3.12

Language Extension Version (if applicable)

v2024.6.0

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

@epicwhale epicwhale added the bug Issue identified by VS Code Team member as probable bug label May 16, 2024
@VSCodeTriageBot VSCodeTriageBot added the triage-needed Issue needs to be triaged label May 16, 2024
@DonJayamanne
Copy link
Contributor

zmq/backend/cython/socket.pyx", line 664, in zmq.backend.cython.socket.Socket.disconnect
zmq.error.ZMQError: No such file or directory

Thank you for filling this issue and sorry you're running into this
Looks like the ipykernel dependencies (namely pyzmq or the like area not installed correctly) , it's not an issue with vscode

please try reinstalling them
Optionally pleasercreate a virtual environment, (or use conda) installing packages into global python envs is generally not recommended and prone to run into issues such as this.

@epicwhale
Copy link
Author

zmq/backend/cython/socket.pyx", line 664, in zmq.backend.cython.socket.Socket.disconnect
zmq.error.ZMQError: No such file or directory

Thank you for filling this issue and sorry you're running into this Looks like the ipykernel dependencies (namely pyzmq or the like area not installed correctly) , it's not an issue with vscode

please try reinstalling them Optionally pleasercreate a virtual environment, (or use conda) installing packages into global python envs is generally not recommended and prone to run into issues such as this.

I am using the official vs code python dev containers
mcr.microsoft.com/devcontainers/python:1-3.12-bullseye

I believe this is managed by VS Code itself? What do you recommend reinstalling here? I thought it comes with the needful dependencies. @DonJayamanne

@epicwhale
Copy link
Author

fwiw: I did a reinstall of whole package for now. Seems to be working inside the dev container

pip uninstall ipykernel
pip install ipykernel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants