-
Notifications
You must be signed in to change notification settings - Fork 174
Description
Environment data
- debugpy version: 1.2.1 (run
import debugpy; print(debugpy.__version__)
if uncertain) - OS and version: Ubuntu 18.04
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.8, Anaconda x64
- Using VS Code or Visual Studio: VS Code
Actual behavior
Breakpoints are not getting hit when reached from a child thread.
This seems to be a regression after version 1.1.0 (shipped with VSCode Python 2020.11.358366026). Updating the Python extension to any version after 2020.11.358366026 (which seem to ship 1.2.0 onwards) breaks this.
Rolling back to 2020.11.358366026 (with 1.1.0) and the debugging works again.
I have tried adding "subProcess": true
but it seems that it doesn't fix this bug in 1.2.0, nor is it required when using 1.1.0 to breakpoint from a child thread.
Expected behavior
Breakpoints are hit in child threads the same way in 1.1.0 and 1.2.0 onwards
Steps to reproduce:
Note this uses a QThread because the issue was encountered in debugging an async core task of a GUI. I am not sure whether a Python thread would work here. To get PyQt5 do pip install PyQt5==5.15.1
from PyQt5 import Qt
class TaskWorkerThread(Qt.QThread):
def __init__(self, task_function):
super(TaskWorkerThread, self).__init__()
self.task_function = task_function
def run(self):
self.result = self.task_function()
def debugging_function():
print(123)
thread = TaskWorkerThread(debugging_function)
thread.start()
And launch.json
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"subProcess": true
},
- Upgrade to the latest Python extension (or any that ship debugpy 1.2.0 or later)
- Copy paste into a file & put a breakpoint on
print(123)
- The process should just exit and the breakpoint will never be triggered
- Downgrade to Python VSCode 2020.11.358366026
- Repeat - you should now see the breakpoint on
print(123)
trigger- Although the server will then exit and stop the debugger as if the process has finished. This might be a separate issue but this bug report is not concerned with that - as long as there is a significant amount of work in the subthread task, then it works fine.