]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-134861: Add 🍌SV output format to ``python -m asyncio ps`` (#137486)
authorDaniele Parmeggiani <8658291+dpdani@users.noreply.github.com>
Wed, 6 Aug 2025 20:42:34 +0000 (22:42 +0200)
committerGitHub <noreply@github.com>
Wed, 6 Aug 2025 20:42:34 +0000 (20:42 +0000)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Lib/asyncio/__main__.py
Lib/asyncio/tools.py

index 4b43ba5dd705141ceca443df502316796ccb2499..5ef2e1f9efc9edacfd09bdbad46a33f969638a9d 100644 (file)
@@ -156,7 +156,10 @@ if __name__ == '__main__':
     )
     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"
     )
index efa8e1844cf3d2a9551c87933469210f6e79d023..3887fb8ab5bf52fc93602a11318a0dd65f779aee 100644 (file)
@@ -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):
@@ -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)