From 6ec928a61ace88a7bf2890c539e2c18c14058836 Mon Sep 17 00:00:00 2001 From: Shankarraospatil Date: Sun, 3 May 2026 13:21:58 +0530 Subject: [PATCH 1/3] Fix incorrect docstring for get_all_awaited_by in _remote_debugging --- Modules/_remote_debugging/module.c | 53 +++++++++++++----------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/Modules/_remote_debugging/module.c b/Modules/_remote_debugging/module.c index 8513bf0e4e65a57..2fc7a24ba5c6c0b 100644 --- a/Modules/_remote_debugging/module.c +++ b/Modules/_remote_debugging/module.c @@ -908,23 +908,18 @@ _remote_debugging_RemoteUnwinder_get_stack_trace_impl(RemoteUnwinderObject *self @critical_section _remote_debugging.RemoteUnwinder.get_all_awaited_by -Get all tasks and their awaited_by relationships from the remote process. - -This provides a tree structure showing which tasks are waiting for -other tasks. +Returns: + A list of AwaitedInfo objects, where each object contains: -For each task, returns: -1. The call stack frames leading to where the task is currently - executing -2. The name of the task -3. A list of tasks that this task is waiting for, with their own - frames/names/etc + - thread_id (int): Identifier of the thread. + - awaited_by (list[TaskInfo]): List of TaskInfo objects representing tasks + awaiting this thread. -Returns a list of [frames, task_name, subtasks] where: -- frames: List of (func_name, filename, lineno) showing the call - stack -- task_name: String identifier for the task -- subtasks: List of tasks being awaited by this task, in same format +Each TaskInfo contains: + - task_id (int): Identifier of the task. + - task_name (str): Name of the task. + - coroutine_stack (list[CoroInfo]): Stack of coroutine frames. + - awaited_by (list[TaskInfo]): Nested tasks awaited by this task. Raises: RuntimeError: If AsyncioDebug section is not available in the @@ -933,24 +928,20 @@ Returns a list of [frames, task_name, subtasks] where: OSError: If reading from the remote process fails Example output: -[ - # Task c2_root waiting for two subtasks + [ - # Call stack of c2_root - [("c5", "script.py", 10), ("c4", "script.py", 14)], - "c2_root", - [ - # First subtask (sub_main_2) and what it's waiting for - [ - [("c1", "script.py", 23)], - "sub_main_2", - [...] - ], - # Second subtask and its waiters - [...] - ] + AwaitedInfo( + thread_id=12345, + awaited_by=[ + TaskInfo( + task_id=1, + task_name="Task-1", + coroutine_stack=[...], + awaited_by=[] + ) + ] + ) ] -] [clinic start generated code]*/ static PyObject * From 1c2fbff75af4f695e4971185334ab6ef9a60ddcb Mon Sep 17 00:00:00 2001 From: Shankarraospatil Date: Sun, 3 May 2026 13:53:51 +0530 Subject: [PATCH 2/3] Regenerate Argument Clinic output after docstring fix --- Modules/_remote_debugging/clinic/module.c.h | 53 ++++++++++----------- Modules/_remote_debugging/module.c | 6 ++- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/Modules/_remote_debugging/clinic/module.c.h b/Modules/_remote_debugging/clinic/module.c.h index 4d63beb91515f84..2b49a3bb9d307a2 100644 --- a/Modules/_remote_debugging/clinic/module.c.h +++ b/Modules/_remote_debugging/clinic/module.c.h @@ -288,23 +288,20 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder_get_all_awaited_by__doc__, "get_all_awaited_by($self, /)\n" "--\n" "\n" -"Get all tasks and their awaited_by relationships from the remote process.\n" +"Get awaited_by relationships for tasks in the remote process.\n" "\n" -"This provides a tree structure showing which tasks are waiting for\n" -"other tasks.\n" +"Returns:\n" +" A list of AwaitedInfo objects, where each object contains:\n" "\n" -"For each task, returns:\n" -"1. The call stack frames leading to where the task is currently\n" -" executing\n" -"2. The name of the task\n" -"3. A list of tasks that this task is waiting for, with their own\n" -" frames/names/etc\n" +" - thread_id (int): Identifier of the thread.\n" +" - awaited_by (list[TaskInfo]): List of TaskInfo objects representing tasks\n" +" awaiting this thread.\n" "\n" -"Returns a list of [frames, task_name, subtasks] where:\n" -"- frames: List of (func_name, filename, lineno) showing the call\n" -" stack\n" -"- task_name: String identifier for the task\n" -"- subtasks: List of tasks being awaited by this task, in same format\n" +"Each TaskInfo contains:\n" +" - task_id (int): Identifier of the task.\n" +" - task_name (str): Name of the task.\n" +" - coroutine_stack (list[CoroInfo]): Stack of coroutine frames.\n" +" - awaited_by (list[TaskInfo]): Nested tasks awaited by this task.\n" "\n" "Raises:\n" " RuntimeError: If AsyncioDebug section is not available in the\n" @@ -313,20 +310,20 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder_get_all_awaited_by__doc__, " OSError: If reading from the remote process fails\n" "\n" "Example output:\n" -"[\n" +"\n" " [\n" -" [(\"c5\", \"script.py\", 10), (\"c4\", \"script.py\", 14)],\n" -" \"c2_root\",\n" -" [\n" -" [\n" -" [(\"c1\", \"script.py\", 23)],\n" -" \"sub_main_2\",\n" -" [...]\n" -" ],\n" -" [...]\n" -" ]\n" -" ]\n" -"]"); +" AwaitedInfo(\n" +" thread_id=12345,\n" +" awaited_by=[\n" +" TaskInfo(\n" +" task_id=1,\n" +" task_name=\"Task-1\",\n" +" coroutine_stack=[...],\n" +" awaited_by=[]\n" +" )\n" +" ]\n" +" )\n" +" ]"); #define _REMOTE_DEBUGGING_REMOTEUNWINDER_GET_ALL_AWAITED_BY_METHODDEF \ {"get_all_awaited_by", (PyCFunction)_remote_debugging_RemoteUnwinder_get_all_awaited_by, METH_NOARGS, _remote_debugging_RemoteUnwinder_get_all_awaited_by__doc__}, @@ -1709,4 +1706,4 @@ _remote_debugging_get_gc_stats(PyObject *module, PyObject *const *args, Py_ssize exit: return return_value; } -/*[clinic end generated code: output=8ad64b51aaffc3ad input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9f71c6f5522a27db input=a9049054013a1b77]*/ diff --git a/Modules/_remote_debugging/module.c b/Modules/_remote_debugging/module.c index 2fc7a24ba5c6c0b..113abe6a4f3d1b7 100644 --- a/Modules/_remote_debugging/module.c +++ b/Modules/_remote_debugging/module.c @@ -904,10 +904,12 @@ _remote_debugging_RemoteUnwinder_get_stack_trace_impl(RemoteUnwinderObject *self } /*[clinic input] -@permit_long_summary +@permit_long_docstring_body @critical_section _remote_debugging.RemoteUnwinder.get_all_awaited_by +Get awaited_by relationships for tasks in the remote process. + Returns: A list of AwaitedInfo objects, where each object contains: @@ -946,7 +948,7 @@ Example output: static PyObject * _remote_debugging_RemoteUnwinder_get_all_awaited_by_impl(RemoteUnwinderObject *self) -/*[clinic end generated code: output=6a49cd345e8aec53 input=c22bfee0612e0b69]*/ +/*[clinic end generated code: output=6a49cd345e8aec53 input=64456ccc05d9bfd2]*/ { if (ensure_async_debug_offsets(self) < 0) { return NULL; From cb217e73b6f832d2d6b732dd30466b71e46fc1fb Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Sun, 4 Oct 2026 21:33:30 +0100 Subject: [PATCH 3/3] Clarify task waiter relationships and fallback task list --- Modules/_remote_debugging/clinic/module.c.h | 15 ++++++++++----- Modules/_remote_debugging/module.c | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Modules/_remote_debugging/clinic/module.c.h b/Modules/_remote_debugging/clinic/module.c.h index 2b49a3bb9d307a2..349113c36fb5f06 100644 --- a/Modules/_remote_debugging/clinic/module.c.h +++ b/Modules/_remote_debugging/clinic/module.c.h @@ -293,15 +293,20 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder_get_all_awaited_by__doc__, "Returns:\n" " A list of AwaitedInfo objects, where each object contains:\n" "\n" -" - thread_id (int): Identifier of the thread.\n" -" - awaited_by (list[TaskInfo]): List of TaskInfo objects representing tasks\n" -" awaiting this thread.\n" +" - thread_id (int): Identifier of the thread, or 0 for tasks in the\n" +" interpreter\'s fallback task list.\n" +" - awaited_by (list[TaskInfo]): Tasks registered with this thread.\n" "\n" "Each TaskInfo contains:\n" " - task_id (int): Identifier of the task.\n" " - task_name (str): Name of the task.\n" " - coroutine_stack (list[CoroInfo]): Stack of coroutine frames.\n" -" - awaited_by (list[TaskInfo]): Nested tasks awaited by this task.\n" +" - awaited_by (list[CoroInfo]): Coroutine information for tasks or futures\n" +" awaiting this task.\n" +"\n" +"Each CoroInfo contains:\n" +" - call_stack (list[FrameInfo]): Call stack frames for the coroutine.\n" +" - task_name (int): Identifier of the task or future.\n" "\n" "Raises:\n" " RuntimeError: If AsyncioDebug section is not available in the\n" @@ -1706,4 +1711,4 @@ _remote_debugging_get_gc_stats(PyObject *module, PyObject *const *args, Py_ssize exit: return return_value; } -/*[clinic end generated code: output=9f71c6f5522a27db input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8424a993a85ef2bd input=a9049054013a1b77]*/ diff --git a/Modules/_remote_debugging/module.c b/Modules/_remote_debugging/module.c index 113abe6a4f3d1b7..c06d7ca635b167f 100644 --- a/Modules/_remote_debugging/module.c +++ b/Modules/_remote_debugging/module.c @@ -913,15 +913,20 @@ Get awaited_by relationships for tasks in the remote process. Returns: A list of AwaitedInfo objects, where each object contains: - - thread_id (int): Identifier of the thread. - - awaited_by (list[TaskInfo]): List of TaskInfo objects representing tasks - awaiting this thread. + - thread_id (int): Identifier of the thread, or 0 for tasks in the + interpreter's fallback task list. + - awaited_by (list[TaskInfo]): Tasks registered with this thread. Each TaskInfo contains: - task_id (int): Identifier of the task. - task_name (str): Name of the task. - coroutine_stack (list[CoroInfo]): Stack of coroutine frames. - - awaited_by (list[TaskInfo]): Nested tasks awaited by this task. + - awaited_by (list[CoroInfo]): Coroutine information for tasks or futures + awaiting this task. + +Each CoroInfo contains: + - call_stack (list[FrameInfo]): Call stack frames for the coroutine. + - task_name (int): Identifier of the task or future. Raises: RuntimeError: If AsyncioDebug section is not available in the @@ -948,7 +953,7 @@ Example output: static PyObject * _remote_debugging_RemoteUnwinder_get_all_awaited_by_impl(RemoteUnwinderObject *self) -/*[clinic end generated code: output=6a49cd345e8aec53 input=64456ccc05d9bfd2]*/ +/*[clinic end generated code: output=6a49cd345e8aec53 input=79e556b3973d21a8]*/ { if (ensure_async_debug_offsets(self) < 0) { return NULL;