Bug:Debug didn't work in Qthread
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start by reproducing the report with the provided main.py and sub_thread.py examples, placing a breakpoint in WorkerThread.run. Then inspect the debugger's thread handling and any existing tests for PySide6 or QThread support. Done means the breakpoint in the worker thread is reached during a VS Code debug session.
Written by the indexing model from the issue text.
Description
Description:
When I use Qt for Pyside6, I open a Qthread sub thread in the main thread and add a breakpoint inside the sub thread, but Python debugger does not enter the sub thread,it just didn't work
Origin Code:
main.py:
import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QTextEdit, QVBoxLayout, QWidget
from PySide6.QtCore import Qt
from worker_thread import WorkerThread
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("QThread Debug Test")
self.setGeometry(100, 100, 400, 300)
# 创建中央部件和布局
central_widget = QWidget()
self.setCentralWidget(central_widget)
layout = QVBoxLayout(central_widget)
# 创建按钮
self.start_button = QPushButton("Start Thread")
self.start_button.clicked.connect(self.start_thread)
layout.addWidget(self.start_button)
# 创建文本显示区域
self.text_edit = QTextEdit()
self.text_edit.setReadOnly(True)
layout.addWidget(self.text_edit)
# 创建工作线程
self.worker_thread = None
def start_thread(self):
if self.worker_thread is None or not self.worker_thread.isRunning():
self.worker_thread = WorkerThread()
self.worker_thread.message_signal.connect(self.update_text)
self.worker_thread.start()
self.text_edit.append("Thread started...")
def update_text(self, message):
self.text_edit.append(message)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())
sub_thread.py:
from PySide6.QtCore import QThread, Signal
import time
class WorkerThread(QThread):
message_signal = Signal(str)
def __init__(self):
super().__init__()
self.running = True
def run(self):
count = 0
while self.running and count < 10:
count += 1
self.message_signal.emit(f"Count: {count}")
time.sleep(1) # 模拟耗时操作
self.message_signal.emit("Thread finished!")
def stop(self):
self.running = False
Where is the sub-thread?
Where is the breakpoint?
What's the Performance?
Set the breakpoint and push the button,then you'll find that Python Debugger didn't work in the workthread(sub-thread)!
- Dominant language
- TypeScript
- Stars
- 181
- Forks
- 126
- Avg merge
- 8h 49m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/vscode-python-debugger
-
triage-needed
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/vscode-python-debugger#1110 ·
-
triage-needed
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
microsoft/vscode-python-debugger#1024 · 1 comment ·
-
triage-needed
microsoft/vscode-python-debugger#1111 · 1 reaction · 1 assignee ·
-
triage-needed
microsoft/vscode-python-debugger#1104 · 1 reaction · 1 assignee ·
-
triage-needed
Difficulty 4/5 3-5 days Newbie friendliness 58/100
microsoft/vscode-python-debugger#1095 · 1 comment · 1 reaction ·
All issues in microsoft/vscode-python-debugger
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
bcgov/bc-wallet-mobile#4761 · 1 comment ·
-
external-issue to-triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
area-deployment area-integrations triage:bot-seen
Difficulty 2/5 Half a day Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
refactor
Difficulty 2/5 1-3 hours Newbie friendliness 84/100