-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Context
Migrating a GAE from Python 2 to Python 3 using legacy bundled services (memcache and deferred).
Expected Behavior
The GAE app can be debugged using debugpy in vscode.
Actual Behavior
After adding a breakpoint on line 4 or 5 in file main.py and hitting with a browser (or curl) http://localhost:8000, the debugger hangs.
Commenting out line 7 (with the call to wrap_wsgi_app() ) and restarting the server temporary removes the issue (but memcache/deferred services are not working).
Same behavior when running using google-cloud-sdk/bin/dev_appserver.py to start gunicorn
When killing the worker, the following traceback is printed:
Traceback
[2025-06-11 17:07:47 +0200] [819688] [INFO] Starting gunicorn 23.0.0
[2025-06-11 17:07:47 +0200] [819688] [INFO] Listening at: http://127.0.0.1:8000 (819688)
[2025-06-11 17:07:47 +0200] [819688] [INFO] Using worker: sync
[2025-06-11 17:07:48 +0200] [819706] [INFO] Booting worker with pid: 819706
^C[2025-06-11 17:13:46 +0200] [819688] [INFO] Handling signal: int
[2025-06-11 17:13:46 +0200] [819706] [ERROR] Error handling request /favicon.ico
Traceback (most recent call last):
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/gunicorn/workers/sync.py", line 134, in handle
self.handle_request(listener, req, client, addr)
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/gunicorn/workers/sync.py", line 177, in handle_request
respiter = self.wsgi(environ, resp.start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 82, in <lambda>
lambda app: lambda wsgi_env, start_resp: f(app, wsgi_env, start_resp),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 306, in InitLegacyRequestOsEnvironMiddleware
return app(wsgi_env, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 82, in <lambda>
lambda app: lambda wsgi_env, start_resp: f(app, wsgi_env, start_resp),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 362, in RunInNewContextMiddleware
return ctx.run(app, wsgi_env, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 82, in <lambda>
lambda app: lambda wsgi_env, start_resp: f(app, wsgi_env, start_resp),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 222, in SetContextFromHeadersMiddleware
return app(wsgi_env, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 82, in <lambda>
lambda app: lambda wsgi_env, start_resp: f(app, wsgi_env, start_resp),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 339, in CallbackMiddleware
return app(wsgi_env, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 82, in <lambda>
lambda app: lambda wsgi_env, start_resp: f(app, wsgi_env, start_resp),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 108, in UseRequestSecurityTicketForApiMiddleware
return app(wsgi_env, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 82, in <lambda>
lambda app: lambda wsgi_env, start_resp: f(app, wsgi_env, start_resp),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 133, in WaitForResponseMiddleware
return list(app(wsgi_env, start_response))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/projects/python-debug-test/main.py", line 5, in app
yield b'Hello world!\n'
^^^^^^^^^^^^^^^^^
File "<stringsource>", line 69, in cfunc.to_py.__Pyx_CFunc_b0409f__29_pydevd_sys_monitoring_cython_object__lParen__etc_to_py_4code_4line.wrap
File "_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx", line 1470, in _pydevd_sys_monitoring_cython._line_event
File "_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx", line 1512, in _pydevd_sys_monitoring_cython._internal_line_event
File "_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx", line 1313, in _pydevd_sys_monitoring_cython._stop_on_breakpoint
File "_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx", line 1950, in _pydevd_sys_monitoring_cython._do_wait_suspend
File "/home/tony/.vscode-server/extensions/ms-python.debugpy-2025.8.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2188, in do_wait_suspend
keep_suspended = self._do_wait_suspend(thread, frame, event, arg, trace_suspend_type, from_this_thread, frames_tracker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.vscode-server/extensions/ms-python.debugpy-2025.8.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2257, in _do_wait_suspend
notify_event.wait(wait_timeout)
File "/usr/lib/python3.12/threading.py", line 655, in wait
signaled = self._cond.wait(timeout)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/threading.py", line 359, in wait
gotit = waiter.acquire(True, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/gunicorn/workers/base.py", line 198, in handle_quit
time.sleep(0.1)
File "/home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/lib/python3.12/site-packages/gunicorn/workers/base.py", line 199, in handle_quit
sys.exit(0)
SystemExit: 0
[2025-06-11 17:13:46 +0200] [819706] [INFO] Worker exiting (pid: 819706)
Exception ignored in thread started by: <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace object at 0x730b1afb9a30>
Traceback (most recent call last):
File "/home/tony/.vscode-server/extensions/ms-python.debugpy-2025.8.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 1131, in __call__
ret = self.original_func(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/threading.py", line 1030, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.12/threading.py", line 1077, in _bootstrap_inner
self._delete()
File "/usr/lib/python3.12/threading.py", line 1109, in _delete
del _active[get_ident()]
~~~~~~~^^^^^^^^^^^^^
KeyError: 126491543201472
Exception ignored in thread started by: <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace object at 0x730b1afb9b50>
Traceback (most recent call last):
File "/home/tony/.vscode-server/extensions/ms-python.debugpy-2025.8.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 1131, in __call__
ret = self.original_func(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/threading.py", line 1030, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.12/threading.py", line 1077, in _bootstrap_inner
self._delete()
File "/usr/lib/python3.12/threading.py", line 1109, in _delete
del _active[get_ident()]
~~~~~~~^^^^^^^^^^^^^
KeyError: 126491551594176
Exception ignored in thread started by: <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace object at 0x730b1afb86e0>
Traceback (most recent call last):
File "/home/tony/.vscode-server/extensions/ms-python.debugpy-2025.8.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 1131, in __call__
[2025-06-11 17:13:47 +0200] [819688] [INFO] Shutting down: Master
Steps to Reproduce the Problem
- Create the example app (2 files listed bellow)
- Set up the debugger via .vscode/launch.json
main.py
import google.appengine.api
def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
yield b'Hello world!\n'
app = google.appengine.api.wrap_wsgi_app(app).vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "gunicorn",
"type": "debugpy",
"request": "launch",
"module": "gunicorn",
"args": [
"--timeout=0",
"--workers=1",
"main:app"
]
}
]
}$ poetry show -T
appengine-python-standard 1.1.10 Google App Engine services SDK for Python 3
gunicorn 23.0.0 WSGI HTTP Server for UNIX
$ poetry env info
Virtualenv
Python: 3.12.3
Implementation: CPython
Path: /home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12
Executable: /home/tony/.cache/pypoetry/virtualenvs/python-debug-test-dEh-hs7b-py3.12/bin/python
Valid: True
Base
Platform: linux
OS: posix
Python: 3.12.3
Path: /usr
Executable: /usr/bin/python3.12
Metadata
Metadata
Assignees
Labels
No labels