MCPcopy Index your code
hub / github.com/python/cpython / _task_print_stack

Function _task_print_stack

Lib/asyncio/base_tasks.py:69–94  ·  view source on GitHub ↗
(task, limit, file)

Source from the content-addressed store, hash-verified

67
68
69def _task_print_stack(task, limit, file):
70 extracted_list = []
71 checked = set()
72 for f in task.get_stack(limit=limit):
73 lineno = f.f_lineno
74 co = f.f_code
75 filename = co.co_filename
76 name = co.co_name
77 if filename not in checked:
78 checked.add(filename)
79 linecache.checkcache(filename)
80 line = linecache.getline(filename, lineno, f.f_globals)
81 extracted_list.append((filename, lineno, name, line))
82
83 exc = task._exception
84 if not extracted_list:
85 print(f'No stack for {task!r}', file=file)
86 elif exc is not None:
87 print(f'Traceback for {task!r} (most recent call last):', file=file)
88 else:
89 print(f'Stack for {task!r} (most recent call last):', file=file)
90
91 traceback.print_list(extracted_list, file=file)
92 if exc is not None:
93 for line in traceback.format_exception_only(exc.__class__, exc):
94 print(line, file=file, end='')

Callers

nothing calls this directly

Calls 6

setFunction · 0.85
format_exception_onlyMethod · 0.80
get_stackMethod · 0.45
addMethod · 0.45
getlineMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…