Jason S
05/23/2022, 3:41 AMKlaus
05/23/2022, 7:27 AMdebugpy
with pip
2) Add a launch configuration for Python in .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug SST Start",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst",
"runtimeArgs": [
"start",
"--increase-timeout"
],
"console": "integratedTerminal",
"skipFiles": [
"<node_internals>/**"
],
"env": {}
},
{
"name": "Python: Attach",
"type": "python",
"localRoot": "${workspaceFolder}/backend/functions",
"request": "attach",
"host": "localhost",
"port": 5678
}
]
}
3) modify the python startup related code in node_modules/@serverless-stack/core/dist/runtime/handler/python.js and replace "-u"
(line 76 for me) by "-m", "debugpy", "--listen", "0.0.0.0:5678" , "--wait-for-client",
4) Make sure you increase the timeout for sst in package.json
...
"scripts": {
"start": "sst start --increase-timeout", // <--
...}
--wait-for-client
option means you now have to launch the debugger (F5 for me on Windows) for the function to runJason S
05/23/2022, 7:49 AMdebugpy
returns the following: RuntimeError: Can't listen for client connections: [Errno 48] Address already in use
5678
from previous attempts with no successlaunch.json
?Klaus
05/23/2022, 7:54 AMJason S
05/23/2022, 7:59 AMnpx sst start
after making the changes to python.js
, right?Klaus
05/23/2022, 8:10 AMnode_modules/@serverless-stack/core/dist/runtime/handler/python.js
you just run npm run start
(whihc use the modified file in the current projectJason S
05/23/2022, 8:31 AMdebugpy
imports or method calls within your lambda function?Klaus
05/23/2022, 9:35 AMnode_modules/@serverless-stack/core/dist/runtime/handler/python.js
file# ...
# for debugging only
import debugpy
debugpy.listen(('0.0.0.0', 5678))
debugpy.wait_for_client()
debugpy.breakpoint()
Jay
05/23/2022, 5:07 PMJason S
05/25/2022, 1:38 AMdebugpy
listener is only listening during the function run.debugpy
listening server is not being run during the SST start procedure.ps aux | grep debugpy
and there is no service running.Florian Fuß
06/17/2022, 6:41 PM