Thread suspend policy for multi-threaded applications #18347
-
I hope this is the right place for this question / discussion, please redirect me if there's a more appropriate place. Consider the following scenario:
This works fine, while the application is running, but when hitting a breakpoint all threads are suspended and any requests fired from the debug console time out, because the forwarder thread is obviously suspended as well. When clicking "Continue" any of the forwarder threads, the MainThread will continue to run as well, which is obviously not the desired behavior. Is there something I am missing here, or is this a limitation of debugpy / the DAP? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
There is a setting you can add to launch json, {
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"steppingResumesAllThreads": false
} |
Beta Was this translation helpful? Give feedback.
-
As a note, the For this case there are 2 options:
i.e.:
If for some reason that's not enough for your use case, feel free to create an issue in https://github.com/microsoft/debugpy/issues. |
Beta Was this translation helpful? Give feedback.
As a note, the
steppingResumesAllThreads
enables making the step only in a single thread without resuming others, but it won't change the behavior that upon hitting a breakpoint all threads are suspended as the behavior is always pausing all threads upon a breakpoint hit...For this case there are 2 options:
Set an environment variable such as
PYDEVD_UNBLOCK_THREADS_TIMEOUT=0
(you may also set a timeout if you wish as 0 will make it resume all threads when the evaluation begins and not only after a given timeout). This will make other threads (all except the one where the evaluation was requested) run during the evaluation (this was done specifically for the use-case you're working with…