From d213176d0f43733007defd4c65f0c95cf7dcdbc8 Mon Sep 17 00:00:00 2001 From: Luke Riddle Date: Tue, 3 Dec 2024 07:20:49 -0800 Subject: [PATCH 1/3] Don't change already suspended threads in subsequent suspend calls --- _pydevd_bundle/pydevd_thread_lifecycle.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_pydevd_bundle/pydevd_thread_lifecycle.py b/_pydevd_bundle/pydevd_thread_lifecycle.py index 2d205c17..19c8a970 100644 --- a/_pydevd_bundle/pydevd_thread_lifecycle.py +++ b/_pydevd_bundle/pydevd_thread_lifecycle.py @@ -28,6 +28,8 @@ def pydevd_find_thread_by_id(thread_id): def mark_thread_suspended(thread, stop_reason: int, original_step_cmd: int = -1): info = set_additional_thread_info(thread) info.suspend_type = PYTHON_SUSPEND + if info.pydev_state != STATE_RUN: + return info if original_step_cmd != -1: stop_reason = original_step_cmd thread.stop_reason = stop_reason @@ -92,6 +94,8 @@ def suspend_all_threads(py_db, except_thread): if t is except_thread: continue info = mark_thread_suspended(t, CMD_THREAD_SUSPEND) + if info.pydev_state != STATE_SUSPEND: + continue frame = info.get_topmost_frame(t) # Reset the tracing as in this case as it could've set scopes to be untraced. From 9c8360452de72d03fec284f3cfaa1e45563caee4 Mon Sep 17 00:00:00 2001 From: Luke Riddle Date: Tue, 3 Dec 2024 07:49:15 -0800 Subject: [PATCH 2/3] Return before suspend_type is set --- _pydevd_bundle/pydevd_thread_lifecycle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pydevd_bundle/pydevd_thread_lifecycle.py b/_pydevd_bundle/pydevd_thread_lifecycle.py index 19c8a970..659d1225 100644 --- a/_pydevd_bundle/pydevd_thread_lifecycle.py +++ b/_pydevd_bundle/pydevd_thread_lifecycle.py @@ -27,9 +27,9 @@ def pydevd_find_thread_by_id(thread_id): def mark_thread_suspended(thread, stop_reason: int, original_step_cmd: int = -1): info = set_additional_thread_info(thread) - info.suspend_type = PYTHON_SUSPEND if info.pydev_state != STATE_RUN: return info + info.suspend_type = PYTHON_SUSPEND if original_step_cmd != -1: stop_reason = original_step_cmd thread.stop_reason = stop_reason From 78f26a11bb66fa31e856df74b24453f788ca3ba1 Mon Sep 17 00:00:00 2001 From: Luke Riddle Date: Tue, 3 Dec 2024 12:05:24 -0800 Subject: [PATCH 3/3] Only skip redundant thread suspends when single notification is enabled --- _pydevd_bundle/pydevd_thread_lifecycle.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_pydevd_bundle/pydevd_thread_lifecycle.py b/_pydevd_bundle/pydevd_thread_lifecycle.py index 659d1225..a3ec478d 100644 --- a/_pydevd_bundle/pydevd_thread_lifecycle.py +++ b/_pydevd_bundle/pydevd_thread_lifecycle.py @@ -25,9 +25,9 @@ def pydevd_find_thread_by_id(thread_id): return None -def mark_thread_suspended(thread, stop_reason: int, original_step_cmd: int = -1): +def mark_thread_suspended(thread, stop_reason: int, original_step_cmd: int = -1, skip_unless_run_state: bool = False): info = set_additional_thread_info(thread) - if info.pydev_state != STATE_RUN: + if skip_unless_run_state and info.pydev_state != STATE_RUN: return info info.suspend_type = PYTHON_SUSPEND if original_step_cmd != -1: @@ -93,7 +93,7 @@ def suspend_all_threads(py_db, except_thread): else: if t is except_thread: continue - info = mark_thread_suspended(t, CMD_THREAD_SUSPEND) + info = mark_thread_suspended(t, CMD_THREAD_SUSPEND, py_db.multi_threads_single_notification) if info.pydev_state != STATE_SUSPEND: continue frame = info.get_topmost_frame(t)