@@ -47,7 +47,7 @@ suitable for inspection and prints its process ID:
4747 tg.create_task(play(track), name = track)
4848
4949 async def main ():
50- print (f " PID: { os.getpid()} " , flush = True )
50+ print (f " PID: { os.getpid()} " )
5151 async with asyncio.TaskGroup() as tg:
5252 tg.create_task(
5353 album(" Sundowning" , [" TNDNBTG" , " Levitate" ]),
@@ -76,30 +76,6 @@ source layouts.
7676Command-line options
7777====================
7878
79- .. option :: ps PID
80-
81- Display a flat table of all pending tasks in the process *PID *. Each row
82- shows the event-loop thread ID, task ID and name, coroutine stack, and the
83- awaiting task's stack, name, and ID, if any.
84-
85- This subcommand prints all tasks regardless of whether the await graph
86- contains cycles. Use it when you need to filter or process task data
87- programmatically, or when the task count is large enough that a tree
88- would be unwieldy:
89-
90- .. code-block :: shell-session
91-
92- $ python -m asyncio ps 12345
93- tid task id task name coroutine stack awaiter chain awaiter name awaiter id
94- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
95- 18445801 0x10a456060 Task-1 TaskGroup._aexit -> TaskGroup.__aexit__ -> main 0x0
96- 18445801 0x10a439f60 Sundowning TaskGroup._aexit -> TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> main Task-1 0x10a456060
97- 18445801 0x10a439d70 TMBTE TaskGroup._aexit -> TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> main Task-1 0x10a456060
98- 18445801 0x10a2a3a80 TNDNBTG sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album Sundowning 0x10a439f60
99- 18445801 0x10a2a38a0 Levitate sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album Sundowning 0x10a439f60
100- 18445801 0x10a2d7150 DYWTYLM sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album TMBTE 0x10a439d70
101- 18445801 0x10a6bdaa0 Aqua Regia sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album TMBTE 0x10a439d70
102-
10379.. option :: pstree PID
10480
10581 Display task and coroutine relationships as a tree. Each task is shown
@@ -147,6 +123,28 @@ Command-line options
147123
148124 cycle: Task-2 → Task-3 → Task-2
149125
126+ .. option :: ps PID
127+
128+ Display a flat table of all pending tasks in the process *PID *. Each row
129+ shows the event-loop thread ID, task ID and name, coroutine stack, and the
130+ awaiting task's stack, name, and ID, if any.
131+
132+ This subcommand prints all tasks regardless of whether the await graph
133+ contains cycles:
134+
135+ .. code-block :: shell-session
136+
137+ $ python -m asyncio ps 12345
138+ tid task id task name coroutine stack awaiter chain awaiter name awaiter id
139+ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
140+ 18445801 0x10a456060 Task-1 TaskGroup._aexit -> TaskGroup.__aexit__ -> main 0x0
141+ 18445801 0x10a439f60 Sundowning TaskGroup._aexit -> TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> main Task-1 0x10a456060
142+ 18445801 0x10a439d70 TMBTE TaskGroup._aexit -> TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> main Task-1 0x10a456060
143+ 18445801 0x10a2a3a80 TNDNBTG sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album Sundowning 0x10a439f60
144+ 18445801 0x10a2a38a0 Levitate sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album Sundowning 0x10a439f60
145+ 18445801 0x10a2d7150 DYWTYLM sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album TMBTE 0x10a439d70
146+ 18445801 0x10a6bdaa0 Aqua Regia sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album TMBTE 0x10a439d70
147+
150148 .. option :: --retries N
151149
152150 Retry failed attempts to inspect the target process up to *N * times. See
0 commit comments