Jason S
05/23/2022, 3:41 AMKlaus
05/23/2022, 7:27 AMKlaus
05/23/2022, 7:34 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", // <--
...}
Klaus
05/23/2022, 7:40 AM--wait-for-client
option means you now have to launch the debugger (F5 for me on Windows) for the function to runKlaus
05/23/2022, 7:44 AMJason S
05/23/2022, 7:49 AMJason S
05/23/2022, 7:50 AMdebugpy
returns the following: RuntimeError: Can't listen for client connections: [Errno 48] Address already in use
Jason S
05/23/2022, 7:50 AM5678
from previous attempts with no successJason S
05/23/2022, 7:51 AMlaunch.json
?Klaus
05/23/2022, 7:54 AMKlaus
05/23/2022, 7:54 AMKlaus
05/23/2022, 7:57 AMJason S
05/23/2022, 7:59 AMJason S
05/23/2022, 8:08 AMnpx sst start
after making the changes to python.js
, right?Klaus
05/23/2022, 8:10 AMKlaus
05/23/2022, 8:11 AMnode_modules/@serverless-stack/core/dist/runtime/handler/python.js
you just run npm run start
(whihc use the modified file in the current projectKlaus
05/23/2022, 8:12 AMKlaus
05/23/2022, 8:15 AMJason 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
fileKlaus
05/23/2022, 9:36 AMKlaus
05/23/2022, 9:39 AM# ...
# for debugging only
import debugpy
debugpy.listen(('0.0.0.0', 5678))
debugpy.wait_for_client()
debugpy.breakpoint()
Klaus
05/23/2022, 3:00 PMJay
Jason S
05/25/2022, 1:38 AMJason S
05/25/2022, 1:39 AMdebugpy
listener is only listening during the function run.Jason S
05/25/2022, 1:40 AMdebugpy
listening server is not being run during the SST start procedure.Jason S
05/25/2022, 1:41 AMps aux | grep debugpy
and there is no service running.Florian Fuß
06/17/2022, 6:41 PM