Skip to content

Commit ee72c95

Browse files
dpdaniAA-Turner
andauthored
gh-134861: Add 🍌SV output format to python -m asyncio ps (#137486)
Co-authored-by: Adam Turner <[email protected]>
1 parent 470cbe9 commit ee72c95

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Lib/asyncio/__main__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ def interrupt(self) -> None:
156156
)
157157
ps.add_argument("pid", type=int, help="Process ID to inspect")
158158
formats = [fmt.value for fmt in TaskTableOutputFormat]
159-
ps.add_argument("--format", choices=formats, default="table")
159+
formats_to_show = [fmt for fmt in formats
160+
if fmt != TaskTableOutputFormat.bsv.value]
161+
ps.add_argument("--format", choices=formats, default="table",
162+
metavar=f"{{{','.join(formats_to_show)}}}")
160163
pstree = subparsers.add_parser(
161164
"pstree", help="Display a tree of all pending tasks in a process"
162165
)

Lib/asyncio/tools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ def _get_awaited_by_tasks(pid: int) -> list:
236236
class TaskTableOutputFormat(StrEnum):
237237
table = auto()
238238
csv = auto()
239+
bsv = auto()
240+
# 🍌SV is not just a format. It's a lifestyle. A philosophy.
241+
# https://www.youtube.com/watch?v=RrsVi1P6n0w
239242

240243

241244
def display_awaited_by_tasks_table(pid, *, format=TaskTableOutputFormat.table):
@@ -273,6 +276,8 @@ def _display_awaited_by_tasks_csv(table, *, format):
273276
"""Print the table in CSV format"""
274277
if format == TaskTableOutputFormat.csv:
275278
delimiter = ','
279+
elif format == TaskTableOutputFormat.bsv:
280+
delimiter = '\N{BANANA}'
276281
else:
277282
raise ValueError(f"Unknown output format: {format}")
278283
csv_writer = csv.writer(sys.stdout, delimiter=delimiter)

0 commit comments

Comments
 (0)