-
Notifications
You must be signed in to change notification settings - Fork 81
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
Python debuggers do not work on code entered through the IDE #2997
Comments
@chipkent A while back, Colin and I were faced with the same issue and found this solution. Could you confirm that it works for you?
As you can see, you need to install pydevd in your (virtual) env first. Both PyCharm and VSCode reply on this package in their debuggers. We even talked about including it as a requirement for the DH server package and enable it by default to make the user experience better but decided to wait for actual user request first. |
VS Code uses Some digging turned up this issue (microsoft/debugpy#474), which suggests trying Riffing on this idea yielded some fruit. If I run: x = mypkg.get_et() in the console, no breakpoints are triggered. But if I run: import debugpy; debugpy.debug_this_thread(); x = mypkg.get_et() in the console, the relevant breakpoints are triggered. Unfortunately, every execution from the console requires
|
Threads that seem to debug fine are
While threads that need
|
From the python threading docs: "There is the possibility that “dummy thread objects” are created. These are thread objects corresponding to “alien threads”, which are threads of control started outside the threading module, such as directly from C code. Dummy thread objects have limited functionality; they are always considered alive and daemonic, and cannot be join()ed. They are never deleted, since it is impossible to detect the termination of alien threads." |
@jmao-denver and I confirmed (at the time) that ensuring We do explicitly create and delete those those thread states in jpy (on the way in/out of py from java). Were you able to to try calling pydevd.settrace on the vendored impl? Given that each ide seems to roll its own, it is unlikely that we'll be able to uniformly handle this in dh or jpy. |
I have tried adding both of these to my test script. Neither resulted in the breakpoints being hit: import pydevd
pydevd.settrace(suspend=False, trace_only_current_thread=False) import debugpy
pydevd = debugpy._vendored.import_module("pydevd")
pydevd.settrace(suspend=False, trace_only_current_thread=False) |
https://code.visualstudio.com/docs/python/debugging Says: import debugpy
debugpy.debug_this_thread() |
Further testing of |
I have continued to look at this problem and test suggestions. The following test cases attempt to debug scripts running in a Docker container with pip-installed Deephaven. https://github.com/chipkent/test-dh-docker-pycharm is using the suggested https://github.com/chipkent/test-dh-docker-pycharm is using VS Code and |
A video of the current debugger status: https://illumon.slack.com/archives/G01K6UHJ00K/p1666369487981179 |
Any java thread will be a "dummy" thread from the context of python (with potentially the exception of the main thread?). For example, start up Deephaven 'normally' (java process that starts a python process), and I'm not sure if there is a generic cpython way to solve this (something like, every thread that java creates needs to call into some sort of python |
This commit adds a configuration option to customize engine-created threads, and provides a default implementation that will register those threads for debugging with pydevd if python is enabled. As of this commit, pydevd debugging seems to work correctly, but VSCode's debugging doesn't work for all threads yet. Partial #2997
In these two repositories, I have been working on getting a debugger working with DH.
https://github.com/chipkent/test-dh-docker-pycharm
https://github.com/chipkent/test-dh-docker-vscode
In both cases, the debugger works for code executed via a
.py
file, but it does not work for code entered via the DH IDE. As a specific example, code entered via the DH IDE does not trigger breakpoints.On the positive side this stuff is confirmed to work in the debugger:
exec
table.update
The easiest way to reproduce the problem is to check out https://github.com/chipkent/test-dh-docker-vscode and follow the directions to use devcontainers in the README. Once the devcontainer is started, add breakpoints in the code, run
run_me.py
under the debugger, and then execute code in the IDE that should trigger the breakpoints. Using this VS Code path to reproduce will be far less painful than using PyCharm, because of #2994.See #2994
The text was updated successfully, but these errors were encountered: