-
Notifications
You must be signed in to change notification settings - Fork 146
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
Debugging Code Running in Host Application #841
Comments
I'm not familiar with Houdini, but it sounds like it has its own Python shell? And you are trying to debug that shell? |
Hi Graham,
I know that several apps (Houdini, Unreal Editor) seem to use Can you see anyway of circumventing this? I actually tried to set |
In this case, you need to call something as:
As it is now, Setting of I'm closing the issue because this should solve it for you (if it doesn't, feel free to comment to reopen the issue). |
@fabioz I'm now trying to debug code and the host application must use Python 2.7.15 and it now refuses to connect.
launch.json{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "127.0.0.1",
"port": 5678
}
}
]
} Here's the code I'm running in the embedded python interpreter from __future__ import print_function
import debugpy
debugpy.log_to("C:\\Users\\Luke\\AppData\\Local\\Temp\\Debugpy")
# Configuring to use the python.exe that is embedded with the application...
# debugpy.configure(python="C:\\Program Files\\Side Effects Software\\Houdini 18.5.351\\python27\\python.exe")
# results in a time out
# As suggested by #532#issuecomment-772370118
# I tried to use the same python version, but this also timed out
debugpy.configure(python="C:\Python27\python.exe")
address = debugpy.listen(address=("0.0.0.0", 5678))
print("Waiting for client on address{}".format(address))
debugpy.wait_for_client() debugpy.server-17384.log I am at a loss as to what to do. |
Do you know how the host application is running this script? If it gets imported as a module, then the import lock is held for the entire duration of the script, meaning that background threads trying to import modules will deadlock; I suspect that this is what's happening here. |
The code above is located in import debug |
That might explain the problem. Instead of having all this code run on module import, try putting it into a function, and then call that function: |
That seems to successfully attach now, but the behaviour is strange. I tried this... from __future__ import print_function
import debugpy
def main():
debugpy.log_to("C:\\Users\\Luke\\AppData\\Local\\Temp\\Debugpy")
debugpy.configure(python="C:\Python27\python.exe")
address = debugpy.listen(address=("0.0.0.0", 5678))
print("Waiting for client on address{}".format(address))
debugpy.wait_for_client()
debugpy.breakpoint() # <-- This doesn't get triggered And break points I've set are not triggered (see attached video) breakpoints.mp4 |
A breakpoint on Depending on where your script is located, though, it might be treated as part of the standard library - this would be the case if you placed it in your "python27" directory (or any subdirectory, such as Lib or site-packages). I would recommend putting it elsewhere and adjusting |
The module location is already in
Should a UNC path of this form work ok? |
Ohh, I'm not sure about that one actually. If you print |
Looks to be correct:
(Just to state the obvious - this is a redacted representation) |
Ok, some human error going on here. I somehow had breakpoints set in files where a drive was mapped, and I was looking at files that were loaded via the UNC path in vscode. I'm still not sure why |
Environment data
Actual behavior
Running
debugpy.listen("localhost", 0))
starts another instance of the host application (Houdini in this case)Expected behavior
It should attach the debugger an not launch the host application.
Steps to reproduce:
sys.path
import debugpy;debugpy.listen(("localhost", 0))
The text was updated successfully, but these errors were encountered: