Skip to content

Commit a1f69b6

Browse files
committed
review
1 parent 58da049 commit a1f69b6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Lib/asyncio/tools.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Tools to analyze tasks running in asyncio programs."""
22

33
from collections import defaultdict, namedtuple
4+
import csv
45
from itertools import count
56
from enum import Enum
67
import sys
78
from _remote_debugging import RemoteUnwinder, FrameInfo
8-
import csv
99

1010

1111
class NodeType(Enum):
@@ -248,37 +248,37 @@ class TaskTableOutputFormat(Enum):
248248

249249
def display_awaited_by_tasks_table(
250250
pid: int,
251-
format_: TaskTableOutputFormat | str = TaskTableOutputFormat.table
251+
format: TaskTableOutputFormat | str = TaskTableOutputFormat.table
252252
) -> None:
253253
"""Build and print a table of all pending tasks under `pid`."""
254254

255255
tasks = _get_awaited_by_tasks(pid)
256256
table = build_task_table(tasks)
257-
format_ = TaskTableOutputFormat(format_)
258-
if format_ == TaskTableOutputFormat.table:
257+
format = TaskTableOutputFormat(format)
258+
if format == TaskTableOutputFormat.table:
259259
_display_awaited_by_tasks_table(table)
260260
else:
261-
_display_awaited_by_tasks_csv(table, format_)
261+
_display_awaited_by_tasks_csv(table, format)
262262

263263

264264
def _display_awaited_by_tasks_table(table) -> None:
265265
# Print the table in a simple tabular format
266266
print(
267-
f"{_header[0]:<10} {_header[1]:<20} {_header[2]:<20} {_header[3]:<50} {_header[4]:<50} {_header[5]:<15} {_header[6]:<15}"
267+
f"{'tid':<10} {'task id':<20} {'task name':<20} {'coroutine stack':<50} {'awaiter chain':<50} {'awaiter name':<15} {'awaiter id':<15}"
268268
)
269269
print("-" * 180)
270270
for row in table:
271271
print(f"{row[0]:<10} {row[1]:<20} {row[2]:<20} {row[3]:<50} {row[4]:<50} {row[5]:<15} {row[6]:<15}")
272272

273273

274-
def _display_awaited_by_tasks_csv(table, format_: TaskTableOutputFormat) -> None:
275-
match format_:
274+
def _display_awaited_by_tasks_csv(table, format: TaskTableOutputFormat) -> None:
275+
match format:
276276
case TaskTableOutputFormat.csv:
277277
delimiter = ','
278278
case TaskTableOutputFormat.bsv:
279279
delimiter = '\N{BANANA}'
280280
case _:
281-
raise ValueError(f"Unknown output format: {format_}")
281+
raise ValueError(f"Unknown output format: {format}")
282282
csv_writer = csv.writer(sys.stdout, delimiter=delimiter)
283283
csv_writer.writerow(_header)
284284
csv_writer.writerows(table)

0 commit comments

Comments
 (0)