1

I've tried this in both VS Code and PyCharm, and both behave the same way. I've got a python application that uses pyads, but I'm not sure there's anything interesting about pyads in particular. The problem is that in either IDE, if I put a breakpoint on a line that will execute as a pyads callback/notification, the code executes but does NOT break.

In the case of pyads, I set up notifications for particular PLC tags. This associates a callback function with that tag, so if the tag's value changes, my callback executes. pyads is just a wrapper around TcAdsDll.dll, and it looks like pyads uses ctypes to do a lot of the heavy lifting. When I place a breakpoint inside the callback and run the code in VS Code or PyCharm (both of which use pydevd), the code executes but the breakpoint does not get hit.

Furthermore, when I print process IDs, thread IDs, and stack traces at different places in the application, I can see that the process ID is the same, but the thread ID is different inside the pyads callback. The stacktrace is particularly interesting. Outside of the pyads callback, the call chain looks like:

runpy.py -> __main__.py -> cli.py -> pydevd_runpy.py -> my actual code

Inside the callback, though, the call chain looks like

pyads\pyads_ex.py -> my callback

I don't know much about pydevd, but I know that all the runpy.py -> __main__.py -> cli.py -> pydevd_runpy.py stuff is done by VS Code to set up the debugger. I would expect (though could easily be wrong) that pydevd would also need to be part of the call chain in the callback in order for my breakpoints to work.

Does anyone have any more insight on this, or is there something that I've misunderstood completely? Any thoughts on how I can set breakpoints in callbacks like this? Thanks!

Edit 07/06/2023 08:19 AM:

My VS Code launch configuration is very basic:

{
    "name": "run-my-thing",
    "type": "python",
    "request": "launch",
    "program": "${workspaceFolder}/run-my-thing.py",
    "console": "integratedTerminal",
    "justMyCode": true
}
maldata
  • 385
  • 1
  • 14
  • Is launch.json configured? – JialeDu Jul 06 '23 at 09:46
  • @JialeDu it is configured with a basic python launch request for the application, but if there are additional options that would affect this behavior, I am not aware of them. I will edit the question with my configuration. – maldata Jul 06 '23 at 13:19

0 Answers0