Reputation: 1
I am running a Flask app under uWSGI on Ubuntu using a VS Code debugpy
configuration. The debugger server runs and attaches to the main thread from wsgi.py
. All breakpoints within the setup and configuration scripts are honored and reflected in the VS Code UI. However, no breakpoints in the Flask routes or other code called from any route are shown in the UI, although the route thread does hang. Inspecting the debugpy.pydevd.log
showed that debugpy
did see the breakpoint and sent the CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION
, which normally calls a set of other commands to get the call stack, etc., but in this case did nothing and did not update the UI, so I could not inspect or continue using VS Code.
name: version (line: 30)
file: /home/headxx-app/apps/services/routes.py
event: line
arg: None
step: CMD_STEP_INTO (original step: <Unknown: -1>)
thread: <_MainThread(uWSGIWorker3Core0, started 140525173644224)>, thread id: pid_25855_id_140525160295696, id(thread): 140525160295696
0.00s - Stack: /home/headxx-app/apps/services/routes.py, version, 30
0.00s - Stack: /home/headxx-app/.local/lib/python3.10/site-packages/flask/app.py, dispatch_request, 150
0.00s - Stack: /home/headxx-app/.local/lib/python3.10/site-packages/flask/app.py, full_dispatch_request, 151
0.00s - Stack: /home/headxx-app/.local/lib/python3.10/site-packages/flask/app.py, wsgi_app, 207
0.00s - Stack: /home/headxx-app/apps/library.py, call, 34
0.00s - Stack: /home/headxx-app/.local/lib/python3.10/site-packages/flask/app.py, call, 209
10.00s - Sending suspend notification.
0.00s - sending cmd (http_json) --> CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION {"type": "event", "event": "stopped", "body": {"reason": "breakpoint", "threadId": 1, "preserveFocusHint": false, "allThreadsStopped": true}, "seq": 110, "pydevd_cmd_id": 157}
I tried using implicit calls in the route, such as:
# debugpy.debug_this_thread()
# debugpy.trace_this_thread(True)
This had the same effect: the breakpoint command was called but not responded to.
I am using SSH to remotely access the server, with all code and debugging done via this remote connection on a remote-only codebase. Port 5678 is mapped back to VS Code running locally.
"version": "0.2.0",
"configurations": [
{
"type": "debugpy",
"request": "attach",
"name": "Launch uWSGI",
"justMyCode": false,
"subProcess": true,
"connect": { "host": "localhost", "port": 5678 },
}
]
wsgi.py
...
debugpy.log_to('/home/headxx-app/log')
debugpy.configure(python="/usr/bin/python3")
debugpy.configure(subProcess=True)
debugpy.listen(("localhost", 5678))
debugpy.wait_for_client()
...
I tried different approaches to binding the script and thread to the VS Code debug client (see above). I expected the breakpoint to show up in the VS Code debug panel.
Upvotes: 0
Views: 522