-
Notifications
You must be signed in to change notification settings - Fork 137
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
debugpy.listen hangs in WSGI app #617
Comments
Can you attach the debugger logs you got from |
Happily, here they are: |
It seems that the connection is not being really completed to connect to the The way I'd do it is probably creating an ssh tunneling for the |
I'm not sure about the semantics of In the identical server / client constellation, the following script works fine: #! /env/python3
import debugpy
debugpy.log_to('/<myhome>/debugpy-test/logs')
debugpy.listen(('0.0.0.0', 5678))
debugpy.wait_for_client()
print("hello, world") Execution is halted by To me it looks like |
You're right, the Can you try to set the following environment variables:
in the server and then try to use it again to see if it does any difference? The way that it works is that in: https://github.com/microsoft/debugpy/blob/v1.3.0/src/debugpy/server/api.py#L255 It's a bit strange that it doesn't throw any error though... if you're up to it, you could change your local version to add some prints in https://github.com/microsoft/debugpy/blob/v1.3.0/src/debugpy/_vendored/pydevd/pydevd.py#L2708 to know where exactly it's halting... |
The WSGI test app does not hang in #! /env/python3
def app(environ, start_response):
import os
import debugpy
os.environ['PYDEVD_LOAD_NATIVE_LIB'] = '0'
os.environ['PYDEVD_USE_CYTHON'] = '0'
debugpy.log_to('/<myhome>/debugpy-test/logs')
debugpy.listen(('0.0.0.0', 5678))
#debugpy.wait_for_client()
#debugpy.breakpoint()
status = '200 OK'
output = b'Hello World!\n'
response_headers = [('Content-Type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
application = app Without setting the environment variables, the This does not happen in the non-WSGI test: #! /env/python3
#import os
import debugpy
#os.environ['PYDEVD_LOAD_NATIVE_LIB'] = '0'
#os.environ['PYDEVD_USE_CYTHON'] = '0'
debugpy.log_to('/<myhome>/debugpy-test/logs')
debugpy.listen(('0.0.0.0', 5678))
debugpy.wait_for_client()
print("hello, world") At that point I should probably admit that I use DLLs that I compile for my Debian/Raspbian debugpy package. For Raspbian, the name of my library is During my tests, I ran into another problem: After the WSGI test, the adapter process is not terminated. Running the test again thus results in a runtime error |
Sorry, wrong button... |
Given that Raspbian is ARM, you really need to disable the compiled bits with:
I just noticed that the code isn't handling the arm case properly (even if you compile yourself)... I'll fix this. As for the If you kill all the python processes and start over with those environment variables, do you still have that issue? |
I think that's what I did in the WSGI test case, I just commented out those lines in the non-WSGI test.
If you are referring to the library naming, here is the patch I use (may be not pretty, but works for me): --- a/src/debugpy/_vendored/pydevd/pydevd_tracing.py
+++ b/src/debugpy/_vendored/pydevd/pydevd_tracing.py
@@ -3,6 +3,7 @@
ENV_FALSE_LOWER_VALUES, GlobalDebuggerHolder, ForkSafeLock
from _pydev_imps._pydev_saved_modules import thread, threading
from _pydev_bundle import pydev_log, pydev_monkey
+from fnmatch import fnmatch
from os.path import os
try:
import ctypes
@@ -143,8 +144,10 @@
suffix = 'amd64'
else:
suffix = 'x86'
-
- filename = os.path.join(os.path.dirname(__file__), 'pydevd_attach_to_process', 'attach_linux_%s.so' % (suffix,))
+
+ libdir = os.path.join(os.path.dirname(__file__), 'pydevd_attach_to_process')
+ libs = [f for f in os.listdir(libdir) if fnmatch(f, 'attach_linux.*.so')]
+ filename = os.path.join(libdir, libs[0] if len(libs) == 1 else 'attach_linux.%s.so' % (suffix,))
elif IS_MAC:
if IS_64BIT_PROCESS: This works in conjunction with two scripts used in the Debian packaging process. One clears the libraries and all intermediate files at the beginning of the build, and one builds the libraries for the target architecture. The resulting library files are
If I kill the adapter process ( |
This smells like some incompatibility issue in the libraries (maybe it wasn't compiled as it should?). Do you know which compiler flags were used to compile (i.e.: it should follow what's in: |
Regarding the i.e.: if a python script calls |
…o all threads. Fixes microsoft#617
…o all threads. Fixes microsoft#617
…o all threads. Fixes microsoft#617 The idea is that the user will be able to compile the target libraries/executables so that the features below work: - tracing to all the threads - attach to process Users will need to compile files in the expected location with the proper <arch> (where <arch> == platform.machine()). In Linux the following file is needed (see linux_and_mac/compile_linux.sh): attach_<arch>.so In Mac the following file is needed (see linux_and_mac/compile_mac.sh): attach_<arch>.dylib In Windows the following files are needed (see windows/compile_windows.bat): attach_<arch>.dll run_code_on_dllmain_<arch>.dll inject_dll_<arch>.exe Note: the actual compilation should use those compile scripts as a guide as different platforms may require different compiler flags.
This is how
It is later renamed to |
Do you mean the case that the extensions are disabled with
If the extensions are enabled and the |
Environment data
Actual behavior
WSGI app does not produce result
Expected behavior
WSGI app should produce response
Steps to reproduce:
I am trying to debug this WSGI application
with this Apache configuration
from a client running Windows 10 20H2.
When I comment out the call to
debugpy.listen
in the WSGI script, I can retrieve the pagehttp://<server>:45678
. But with the script as shown above, it hangs. The last entry to the server log is that ofpydevd.settrace
.I can start debugging on the client, but then do nothing:
The text was updated successfully, but these errors were encountered: