Skip to content

Commit 008d552

Browse files
committed
gh-134861: Add 🍌SV output format to asyncio ps
1 parent 03c655b commit 008d552

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ def _get_awaited_by_tasks(pid: int) -> list:
237237
class TaskTableOutputFormat(StrEnum):
238238
table = auto()
239239
csv = auto()
240+
bsv = auto()
241+
# 🍌SV is not just a format. It's a lifestyle. A philosophy.
242+
# https://www.youtube.com/watch?v=RrsVi1P6n0w
240243

241244

242245
def display_awaited_by_tasks_table(
@@ -269,6 +272,8 @@ def _display_awaited_by_tasks_csv(table, format: TaskTableOutputFormat) -> None:
269272
'awaiter chain', 'awaiter name', 'awaiter id')
270273
if format == TaskTableOutputFormat.csv:
271274
delimiter = ','
275+
elif format == TaskTableOutputFormat.bsv:
276+
delimiter = '\N{BANANA}'
272277
else:
273278
raise ValueError(f"Unknown output format: {format}")
274279
csv_writer = csv.writer(sys.stdout, delimiter=delimiter)

0 commit comments

Comments
 (0)