Problem attaching debugger to running C++ app with embedded python
Hi,
I'm trying to attach debugger to running C++ application which embeds the python, but it fails with "Connection to Python debugger failed: Accept timed out". Does anyone know what could be wrong? Is this even supported?
I'm on Windows 7. The application is build using VS 2017.
Thanks
Please sign in to leave a comment.
>running C++ application which embeds the python
Do you mean Cython?
https://youtrack.jetbrains.com/issue/PY-9476
https://youtrack.jetbrains.com/issue/PY-21736
No, I mean application does embed classic CPython. That is, you can use python scripts which are interpreted in application. Nothing fancy. And I want to debug the interpreted python code only.
None of the links provided are related to my problem.
Here is some "debug" log from script using to attach to process:
Anyone, please?
So after some debugging I found the culprit.
My application is single threaded and therefor the GIL is always acquired by the main thread. But because PyCharm debugger create new thread in my process and try to acquire the lock it isn't successful, because I never giveup the GIL (ok, this is not entirely true, because some internal py functions does release GIL for some operations and only then could PyCharm's debugger code be executed).
One option is to release/acquire the GIL on demand in my application but this isn't practical at all (a lot of interwinded code).
But I want to mention, that the Visual Studio PTVS *DOES* support debugging my application. So maybe PyCharm way of debugging isn't bulletproof and only is suitable for debugging the py programs run by python.exe or so.