diff --git a/Modules/_remote_debugging/clinic/module.c.h b/Modules/_remote_debugging/clinic/module.c.h index 179a7b97dd4e2f..7a7bbe68929f62 100644 --- a/Modules/_remote_debugging/clinic/module.c.h +++ b/Modules/_remote_debugging/clinic/module.c.h @@ -277,19 +277,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 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 executing\n" -"2. The name of the task\n" -"3. A list of tasks that this task is waiting for, with their own 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 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 remote process\n" @@ -297,20 +298,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__}, @@ -1563,4 +1564,4 @@ _remote_debugging_get_gc_stats(PyObject *module, PyObject *const *args, Py_ssize exit: return return_value; } -/*[clinic end generated code: output=1151e58683dab9f4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=18ef0c0c482da0ea input=a9049054013a1b77]*/ diff --git a/Modules/_remote_debugging/module.c b/Modules/_remote_debugging/module.c index c840c59971c478..039863d12c17a9 100644 --- a/Modules/_remote_debugging/module.c +++ b/Modules/_remote_debugging/module.c @@ -718,24 +718,24 @@ _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 all tasks and their awaited_by relationships from the remote process. +Get awaited_by relationships for tasks in 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 remote process @@ -743,29 +743,25 @@ 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 * _remote_debugging_RemoteUnwinder_get_all_awaited_by_impl(RemoteUnwinderObject *self) -/*[clinic end generated code: output=6a49cd345e8aec53 input=307f754cbe38250c]*/ +/*[clinic end generated code: output=6a49cd345e8aec53 input=71432c74fb386a75]*/ { if (ensure_async_debug_offsets(self) < 0) { return NULL;