Closed ghaefele closed 2 years ago
With debugpy version 1.2.1, debugging of Python toolboxes (ArcGIS Pro 2.6.3) now works fine, at least with the attach configuration.
Another small problem remains: If the debugging is interrupted prematurely, the processes (Python, Console Host Window, CefSharp.BrowserSubrocess) remain and ArcGIS Pro must be restarted in order to debug again.
If the debugging is interrupted prematurely, the processes (Python, Console Host Window, CefSharp.BrowserSubrocess) remain and ArcGIS Pro must be restarted in order to debug again.
What do you mean by interrupted prematurely
?
Note: the expected process is that you call debugpy.listen(...)
once and then you should be able to attach / disconnect many times (so, if it's something within those boundaries it's a bug, but if it's not it's really something unsupported).
I meant if I disconnect then I can't attach again.
What is the lifecycle of Python code in ArcGIS like? Is there some main thread that stays alive all the time?
I suspect that what's happening here is that your code runs to completion, and then the host kills all remaining Python threads (including the one waiting on the socket).
With debugpy version 1.2.1, debugging of Python toolboxes (ArcGIS Pro 2.6.3) now works fine, at least with the attach configuration.
@ghaefele - I realize this is pretty old but I'm curious how you configured VS code to debug arcgis python toolboxes, been trying for a bit with no luck.
Environment data
Actual behavior
Starting a ArcGIS Pro Python Toolbox tool and then the debug task (attach) in VS Code brings up the debugger button toolbar, but nothing happens after that.
Expected behavior
Start debugging should attach and stop at first breakpoint.
Background
A Python Toolbox tool runs within ArcGIS Pro (embedded Python) and for debugging it is necessary to remote attach to this process. The debug server seems to start successfully. According to the adapter log file there are additional ports/processes involved.
But both sides stay in a waiting status until the debugging process and the Python Toolbox tool are stopped. The processes (LISTENING…) still exists after this. Debugpy does not remove these processes on exit. After that it is not possible to start the tool or the debugging process again. The existing processes seems to block everything. I have to remove the processes manually (
taskkill /PID … /F
).Debugging with ptvsd worked more or less well until June 2020.
Configuration
launch.json
Code (Python Toolbox tool) The issues #387 and #262 solved the problem that the listen process created a new ArcGIS Pro process. The workaround with sys.executable therefore can now be omitted.
Log files
It is noticeable in the adapter log file that the ArcGIS Pro process is listed and not the Python process that was started by ArcGIS Pro. debugpy.adapter-15908.log debugpy.server-10300.log