This is a simple demo project demonstrating an issue with PyCharm 2026.1's "Attach to DAP" debug configuration.
This project uses cmake, so can be adapted most reasonable environments, given sufficient knowledge of cmake.
Some code in main.cpp assumes this is a Windows system. (I do not know if this issue exists on non-Windows systems.)
The commands I use are as follows.
# Setup the venv with uv
$ uv sync [--python <ver>]
$ .venv\Scripts\activate.bat
# setup vcvars
# - only when building with MSVC.
# - the path depends on your Visual Studio install location.
$ pushd "C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build"
$ vcvarsall x64
$ popd
# configure project
# - the venv must be active for pybind11 to find the
# correct Python version.
# - any generator may be used; I prefer Ninja+MSVC.
$ cmake -S . -B build -G Ninja [--fresh]
# build demo
$ cmake --build build
# run demo
# - the appropriate python3xx.dll must be on PATH.
$ build\demo.exeTo execute the demo, configure an "Attach to DAP" debug configuration in PyCharm,
using host "localhost" and port "5678". Set a breakpoint in foo.py in the body of fn().
Then build and run the demo program as described above. Once execution reaches
debugpy.wait_for_client(), launch the "Attach to DAP" debug configuration
to attach to the program.
Then use Resume Program (F5) each time a breakpoint is hit. When a breakpoint is hit from the non-main thread, the Resume Program will instead make the program hang.
Set a breakpoint in foo.py in the body of fn(). Then build and run the demo program
as described above. Once execution reaches debugpy.wait_for_client(), launch the
"Python Remote Connect" configuration (see .vscode/launch.json) to attach to the program.
Then use Resume Program (F5) each time a breakpoint is hit. The program does not hang, even when a breakpoint is hit from the non-main thread.