(result)
| 177 | |
| 178 | |
| 179 | def build_task_table(result): |
| 180 | id2name, _, _ = _index(result) |
| 181 | table = [] |
| 182 | |
| 183 | for awaited_info in result: |
| 184 | thread_id = awaited_info.thread_id |
| 185 | for task_info in awaited_info.awaited_by: |
| 186 | # Get task info |
| 187 | task_id = task_info.task_id |
| 188 | task_name = task_info.task_name |
| 189 | |
| 190 | # Build coroutine stack string |
| 191 | frames = [frame for coro in task_info.coroutine_stack |
| 192 | for frame in coro.call_stack] |
| 193 | coro_stack = " -> ".join(_format_stack_entry(x).split(" ")[0] |
| 194 | for x in frames) |
| 195 | |
| 196 | # Handle tasks with no awaiters |
| 197 | if not task_info.awaited_by: |
| 198 | table.append([thread_id, hex(task_id), task_name, coro_stack, |
| 199 | "", "", "0x0"]) |
| 200 | continue |
| 201 | |
| 202 | # Handle tasks with awaiters |
| 203 | for coro_info in task_info.awaited_by: |
| 204 | parent_id = coro_info.task_name |
| 205 | awaiter_frames = [_format_stack_entry(x).split(" ")[0] |
| 206 | for x in coro_info.call_stack] |
| 207 | awaiter_chain = " -> ".join(awaiter_frames) |
| 208 | awaiter_name = id2name.get(parent_id, "Unknown") |
| 209 | parent_id_str = (hex(parent_id) if isinstance(parent_id, int) |
| 210 | else str(parent_id)) |
| 211 | |
| 212 | table.append([thread_id, hex(task_id), task_name, coro_stack, |
| 213 | awaiter_chain, awaiter_name, parent_id_str]) |
| 214 | |
| 215 | return table |
| 216 | |
| 217 | def _print_cycle_exception(exception: CycleFoundException): |
| 218 | print("ERROR: await-graph contains cycles - cannot print a tree!", file=sys.stderr) |
no test coverage detected
searching dependent graphs…