Skip to content

Commit e44226d

Browse files
committed
make it a secret 🤫
1 parent 21b581a commit e44226d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

‎Lib/asyncio/__main__.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ def interrupt(self) -> None:
154154
)
155155
ps.add_argument("pid", type=int, help="Process ID to inspect")
156156
formats = [fmt.value for fmt in asyncio.tools.TaskTableOutputFormat]
157-
ps.add_argument("--format", choices=formats, default="table")
157+
big_secret = asyncio.tools.TaskTableOutputFormat.bsv.value
158+
formats_to_show = [
159+
fmt for fmt in formats if fmt != big_secret
160+
]
161+
formats_to_show_str = f"{{{','.join(formats_to_show)}}}"
162+
ps.add_argument("--format", choices=formats, default="table",
163+
metavar=formats_to_show_str)
158164
pstree = subparsers.add_parser(
159165
"pstree", help="Display a tree of all pending tasks in a process"
160166
)

‎Lib/asyncio/tools.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,15 @@ class TaskTableOutputFormat(Enum):
217217
_header = ('tid', 'task id', 'task name', 'coroutine chain', 'awaiter name', 'awaiter id')
218218

219219

220-
def display_awaited_by_tasks_table(pid: int, format_: TaskTableOutputFormat = TaskTableOutputFormat.table) -> None:
220+
def display_awaited_by_tasks_table(
221+
pid: int,
222+
format_: TaskTableOutputFormat | str = TaskTableOutputFormat.table
223+
) -> None:
221224
"""Build and print a table of all pending tasks under `pid`."""
222225

223226
tasks = _get_awaited_by_tasks(pid)
224227
table = build_task_table(tasks)
228+
format_ = TaskTableOutputFormat(format_)
225229
if format_ == TaskTableOutputFormat.table:
226230
_display_awaited_by_tasks_table(table)
227231
else:

0 commit comments

Comments
 (0)