FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-134861: Add 🍌SV output format to `asyncio ps` by dpdani · Pull Request #137486 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion Lib/asyncio/__main__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ def interrupt(self) -> None:
)
ps.add_argument("pid", type=int, help="Process ID to inspect")
formats = [fmt.value for fmt in TaskTableOutputFormat]
ps.add_argument("--format", choices=formats, default="table")
formats_to_show = [fmt for fmt in formats
if fmt != TaskTableOutputFormat.bsv.value]
ps.add_argument("--format", choices=formats, default="table",
metavar=f"{{{','.join(formats_to_show)}}}")
pstree = subparsers.add_parser(
"pstree", help="Display a tree of all pending tasks in a process"
)
Expand Down
5 changes: 5 additions & 0 deletions Lib/asyncio/tools.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ def _get_awaited_by_tasks(pid: int) -> list:
class TaskTableOutputFormat(StrEnum):
table = auto()
csv = auto()
bsv = auto()
# 🍌SV is not just a format. It's a lifestyle. A philosophy.
# https://www.youtube.com/watch?v=RrsVi1P6n0w


def display_awaited_by_tasks_table(pid, *, format=TaskTableOutputFormat.table):
Expand Down Expand Up @@ -273,6 +276,8 @@ def _display_awaited_by_tasks_csv(table, *, format):
"""Print the table in CSV format"""
if format == TaskTableOutputFormat.csv:
delimiter = ','
elif format == TaskTableOutputFormat.bsv:
delimiter = '\N{BANANA}'
else:
raise ValueError(f"Unknown output format: {format}")
csv_writer = csv.writer(sys.stdout, delimiter=delimiter)
Expand Down
Loading

Back | FazBrowse Home | New Git URL