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

Timed out waiting for debugger to spawn #239

Closed
hosam00 opened this issue May 12, 2020 · 15 comments
Closed

Timed out waiting for debugger to spawn #239

hosam00 opened this issue May 12, 2020 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@hosam00
Copy link

hosam00 commented May 12, 2020

Hello
I'm using the debugger with python and it gives me this wired message
"timed out waiting for debugger to spawn "
I'm using python 3.8.2 and version of vscode is 1.45

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python May 12, 2020
@int19h
Copy link
Contributor

int19h commented May 12, 2020

What's the version of the Python extension? Can you share your launch.json configuration?

Does it print anything in the terminal? If you're setting "console": "internalConsole", try switching it to "integratedTerminal".

@hosam00
Copy link
Author

hosam00 commented May 12, 2020

Python extension version is: 2020.5.78807

my launch.json file is :

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Gulp task",
"program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js",
"args": [
"task"
],
"skipFiles": [
"<node_internals>/**"
]
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}

and that what is printed in the terminal
cmd /C "set "DEBUGPY_LAUNCHER_PORT=63877" && C:\Users\hosam\AppData\Local\Programs\Python\Python38-32\python.exe c:\Users\hosam.vscode\extensions\ms-python.python-2020.4.76186\pythonFiles\lib\python\debugpy\no_wheels\debugpy\launcher e:\test\testFeatures.py "

@hosam00
Copy link
Author

hosam00 commented May 12, 2020

update :
cmd /C "C:\Users\hosam\AppData\Local\Programs\Python\Python38-32\python.exe c:\Users\hosam.vscode\extensions\ms-python.python-2020.5.78807\pythonFiles\lib\python\debugpy\no_wheels\debugpy\launcher 64771 -- e:\test\testFeatures.py "

@hosam00
Copy link
Author

hosam00 commented May 12, 2020

New message: "Timed out waiting for launcher to connect"
it no gives a new message on the terminal
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

@int19h
Copy link
Contributor

int19h commented May 12, 2020

Alright, at least it's finding it! Can you please add this to your launch.json configuration:

"logToFile": true

and then look for files named debugpy*.log in the directory where the extension is installed - c:\Users\hosam.vscode\extensions\ms-python.python-2020.5.78807. These should allow us to diagnose what's going wrong here.

@hosam00
Copy link
Author

hosam00 commented May 12, 2020

This is what is the file said:
0 Starting Session:
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "e:\test\testFeatures.py",
"console": "integratedTerminal",
"logToFile": true,
"pythonPath": "C:\Users\hosam\AppData\Local\Programs\Python\Python38-32\python.exe",
"cwd": "e:\test",
"envFile": "e:\test/.env",
"env": {
"PYTHONIOENCODING": "UTF-8",
"PYTHONUNBUFFERED": "1"
},
"stopOnEntry": false,
"showReturnValue": true,
"internalConsoleOptions": "neverOpen",
"debugOptions": [
"ShowReturnValue",
"FixFilePathCase"
],
"justMyCode": true,
"workspaceFolder": "e:\test"
}
77 Client --> Adapter:
{
"command": "initialize",
"arguments": {
"clientID": "vscode",
"clientName": "Visual Studio Code",
"adapterID": "python",
"pathFormat": "path",
"linesStartAt1": true,
"columnsStartAt1": true,
"supportsVariableType": true,
"supportsVariablePaging": true,
"supportsRunInTerminalRequest": true,
"locale": "en-us",
"supportsProgressReporting": true
},
"type": "request",
"seq": 1
}
3174 Client <-- Adapter:
{
"seq": 1,
"type": "event",
"event": "output",
"body": {
"category": "telemetry",
"output": "ptvsd",
"data": {
"packageVersion": "1.0.0b9"
}
}
}
3179 Client <-- Adapter:
{
"seq": 2,
"type": "event",
"event": "output",
"body": {
"category": "telemetry",
"output": "debugpy",
"data": {
"packageVersion": "1.0.0b9"
}
}
}
3238 Client <-- Adapter:
{
"seq": 3,
"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,
"supportsHitConditionalBreakpoints": true,
"supportsLogPoints": true,
"supportsModulesRequest": true,
"supportsSetExpression": true,
"supportsSetVariable": true,
"supportsValueFormattingOptions": true,
"supportsTerminateDebuggee": true,
"supportsGotoTargetsRequest": true,
"exceptionBreakpointFilters": [
{
"filter": "raised",
"label": "Raised Exceptions",
"default": false
},
{
"filter": "uncaught",
"label": "Uncaught Exceptions",
"default": true
}
]
}
}
3251 Client --> Adapter:
{
"command": "launch",
"arguments": {
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "e:\test\testFeatures.py",
"console": "integratedTerminal",
"logToFile": true,
"pythonPath": "C:\Users\hosam\AppData\Local\Programs\Python\Python38-32\python.exe",
"cwd": "e:\test",
"envFile": "e:\test/.env",
"env": {
"PYTHONIOENCODING": "UTF-8",
"PYTHONUNBUFFERED": "1"
},
"stopOnEntry": false,
"showReturnValue": true,
"internalConsoleOptions": "neverOpen",
"debugOptions": [
"ShowReturnValue",
"FixFilePathCase"
],
"justMyCode": true,
"workspaceFolder": "e:\test",
"__sessionId": "327c7e51-1674-42f4-9d62-ec27be480caf"
},
"type": "request",
"seq": 2
}
3370 Client <-- Adapter:
{
"seq": 4,
"type": "request",
"command": "runInTerminal",
"arguments": {
"kind": "integrated",
"title": "Python Debug Console",
"args": [
"C:\Users\hosam\AppData\Local\Programs\Python\Python38-32\python.exe",
"c:\Users\hosam\.vscode\extensions\ms-python.python-2020.5.78807\pythonFiles\lib\python\debugpy\no_wheels\debugpy\launcher",
"62191",
"--",
"e:\test\testFeatures.py"
],
"env": {
"DEBUGPY_LOG_DIR": "c:\Users\hosam\.vscode\extensions\ms-python.python-2020.5.78807"
},
"cwd": "e:\test"
}
}
9577 Client --> Adapter:
{
"type": "response",
"seq": 3,
"command": "runInTerminal",
"request_seq": 4,
"success": true,
"body": {
"shellProcessId": 8868
}
}
24145 Client <-- Adapter:
{
"seq": 5,
"type": "response",
"request_seq": 2,
"success": false,
"command": "launch",
"message": "Timed out waiting for debuggee to spawn"
}
24172 Client --> Adapter:
{
"command": "disconnect",
"arguments": {
"restart": false
},
"type": "request",
"seq": 4
}
24816 Client <-- Adapter:
{
"seq": 6,
"type": "event",
"event": "exited",
"body": {
"exitCode": 1
}
}
24826 Client <-- Adapter:
{
"seq": 7,
"type": "event",
"event": "terminated"
}
24830 Client <-- Adapter:
{
"seq": 8,
"type": "response",
"request_seq": 4,
"success": true,
"command": "disconnect"
}
25136 Stopping Session
27462 Error:
{}
27497 Exit:
Exit-Code: 1
Signal: none

and it start giving me the old message again

@int19h
Copy link
Contributor

int19h commented May 12, 2020

There should be more than one file matching the pattern in that directory. The ones I'm particularly interested in are debugpy.adapter*.log, debugpy.server*.log, and debugpy.launcher*.log.

@hosam00
Copy link
Author

hosam00 commented May 12, 2020

debugger.vscode_e65c035f-05d7-4581-801b-880ff4ca624d.log
debugpy.adapter-22396.log
debugpy.launcher-21832.log

Here it is the three files you asked for
I can't find debugpy.server

@int19h
Copy link
Contributor

int19h commented May 12, 2020

Judging by the time stamps in the log, it just takes a lot of time to start every process involved (and each debug session has several!). For example, the launcher process doesn't even get to write the very first log entry until 7 seconds after it has been spawned. And when the launcher tries to use "runInTerminal" request to start the debuggee, it takes 10 seconds for the IDE to come back with a response to that. Our timeouts are generous, but they're not that generous...

So, the real question here is why it takes so long to spawn processes. Is that something that you can observe when starting things manually? E.g. if you just do py -3 testFeatures.py in the terminal, does that start running your code immediately, or is there a noticeable delay?

Also, you appear to be using Python installed from the Microsoft Store. Try using official installers from https://www.python.org/downloads/ - I'm not sure it would make any difference, but it doesn't hurt to try to narrow it down.

@hosam00
Copy link
Author

hosam00 commented May 12, 2020

okay there is a noticeable delay when I run the code from the integrated terminal
But I'm sure that I downloaded Python from official installers

@int19h
Copy link
Contributor

int19h commented May 12, 2020

Python in Microsoft Store is official. But it's still relatively new compared to the regular installers, and there are issues every now and then, so I'm wondering if you are running into one that is specific to the Store.

This is the Store version - you should be able to uninstall it after opening it in the Store app:
https://www.microsoft.com/en-us/p/python-38/9mssztt1n39l

This is the regular installer:
https://www.python.org/ftp/python/3.8.2/python-3.8.2.exe

(You can also have both versions installed side by side, and pick the one that you want to use via the Python version selector on the status bar. But it might get confusing when you're using them directly from command line, because only one of them will be on PATH.)

@hosam00
Copy link
Author

hosam00 commented May 12, 2020

I meant from their website, not from Microsoft store
I double-checked my Microsoft account and I didn't download it from it
I have the exe file 'python-3.8.2.exe'

@int19h
Copy link
Contributor

int19h commented May 12, 2020

Ah, I see - it was AppData in path to the Python binary that threw me off, but this also happens if you use the installer with per-user option. My apologies for the confusion.

Either way, the fundamental problem is the slowdown. Are you only seeing that in VSCode integrated terminal, or is it also happening in the system terminal? Is there anything unusual in Process Explorer, e.g. overuse physical memory, or perhaps too many background processes - especially python.exe ones?

@blackpill
Copy link

I faced the same problem.
Since I didn't know how to optimize the launch time, I solved the problem by changing the timeout from 10 to 20.
Maybe adding a timeout parameter is necessary.

@int19h int19h added the bug Something isn't working label Jun 16, 2020
@int19h
Copy link
Contributor

int19h commented Jun 25, 2020

We've since seen CI tests occasionally affected by timeouts (probably due to heavy load). Between that and your reports from the wild, I'm going to do two things:

  1. Make process spawn & exit timeouts configurable. Since this is still very much an edge case, this will be an environment variable rather than a config property, because that greatly simplifies implementation.

  2. Increase the default for process spawn to 15. Hopefully this will be enough - we can revisit if it still shows up.

@int19h int19h self-assigned this Jun 25, 2020
@int19h int19h changed the title timed out waiting for debugger to spawn Timed out waiting for debugger to spawn Jun 25, 2020
int19h added a commit to int19h/debugpy that referenced this issue Jun 25, 2020
Make timeouts for process spawning and exiting configurable, and increase the default value for spawning.
@int19h int19h closed this as completed in 445c050 Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants