Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make it a secret 🤫
  • Loading branch information
dpdani committed May 31, 2025
commit e44226d82a7c54811cad6ee4b7a7d770b6392f54
8 changes: 7 additions & 1 deletion Lib/asyncio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ def interrupt(self) -> None:
)
ps.add_argument("pid", type=int, help="Process ID to inspect")
formats = [fmt.value for fmt in asyncio.tools.TaskTableOutputFormat]
ps.add_argument("--format", choices=formats, default="table")
big_secret = asyncio.tools.TaskTableOutputFormat.bsv.value
formats_to_show = [
fmt for fmt in formats if fmt != big_secret
]
formats_to_show_str = f"{{{','.join(formats_to_show)}}}"
ps.add_argument("--format", choices=formats, default="table",
metavar=formats_to_show_str)
pstree = subparsers.add_parser(
"pstree", help="Display a tree of all pending tasks in a process"
)
Expand Down
6 changes: 5 additions & 1 deletion Lib/asyncio/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,15 @@ class TaskTableOutputFormat(Enum):
_header = ('tid', 'task id', 'task name', 'coroutine chain', 'awaiter name', 'awaiter id')


def display_awaited_by_tasks_table(pid: int, format_: TaskTableOutputFormat = TaskTableOutputFormat.table) -> None:
def display_awaited_by_tasks_table(
pid: int,
format_: TaskTableOutputFormat | str = TaskTableOutputFormat.table
) -> None:
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
"""Build and print a table of all pending tasks under `pid`."""

tasks = _get_awaited_by_tasks(pid)
table = build_task_table(tasks)
format_ = TaskTableOutputFormat(format_)
if format_ == TaskTableOutputFormat.table:
_display_awaited_by_tasks_table(table)
else:
Expand Down
Loading