-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breakpoints not working with QThread/PySide2 #304
Comments
The debugger side of things seems to be working - if I manually enable debugpy on the background thread it works as intended: import sys
import threading
from PySide2.QtCore import QObject, QThread, Slot
from PySide2.QtWidgets import QApplication, QPushButton
class MyQThread(QThread):
def run(self, *args, **kwargs):
import debugpy
debugpy.debug_this_thread()
super().run()
class Receiver(QObject):
@Slot()
def test(self):
print(f"Received Event on thread {threading.current_thread().name}")
if __name__ == "__main__":
app = QApplication(sys.argv)
button = QPushButton("Hello World!")
button.show()
thread = MyQThread()
receiver = Receiver()
receiver.moveToThread(thread)
thread.start()
button.clicked.connect(receiver.test)
app.exec_() |
Qt monkey-patching is supposed to be enabled by default, but it looks like we regressed that. |
Looks like we regressed it quite a while ago, actually - before ptvsd became debugpy, even. Since it's not an easy revert, I'm going to do this properly - as a configurable property exposing the entire gamut of relevant pydevd settings, to allow fine tuning. The default will still be "auto" though, matching ptvsd 4 behavior. |
Expose pydevd.enable_qt_support() in debugpy.server via debugpy.configure(qt=...) and --configure-qt ... Expose the same in debugpy.adapter via "qt" debug configuration property. Default to "auto" for all of the above, and also provide "none" to disable Qt monkey-patching entirely.
Can you elaborate whether this is fixed? I have the same issue on the latest python extension, failing to capture breakpoints in a QThread. The fix reference above seem to add a command option, but I don't see how to use it. (Or rather, how to use it with VSCode launch options with the Python extension). |
This should be fixed... There are 2 modes of operation, one in which the debugger can debug qt out of the box (when you use Python 3.6 onwards and its compiled extensions are available) and the other which requires some monkey-patching from the debugger. Given that it's not working for you, you're probably on the 2nd case. So, to turn on that monkey-patching, please set:
-- note: it seems |
Environment data
First detected with general release of Python extension and also reproduced with the Insiders edition.
Actual behavior
Breakpoints in an object moved to a new QThread are not triggered
Expected behavior
Breakpoints should work as normal.
I tried to work out if the Qt monkey-patching was being triggered properly, but debugging a debugger was beyond me! Is there any way to check if this has happened?
Steps to reproduce:
pip install PySide2
print
insideReceiver.test
(L11)VS Code launch.json
The text was updated successfully, but these errors were encountered: