Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../asyncio
File: base_tasks.py
import linecache
[0] Fix | Delete
import traceback
[1] Fix | Delete
[2] Fix | Delete
from . import base_futures
[3] Fix | Delete
from . import coroutines
[4] Fix | Delete
[5] Fix | Delete
[6] Fix | Delete
def _task_repr_info(task):
[7] Fix | Delete
info = base_futures._future_repr_info(task)
[8] Fix | Delete
[9] Fix | Delete
if task._must_cancel:
[10] Fix | Delete
# replace status
[11] Fix | Delete
info[0] = 'cancelling'
[12] Fix | Delete
[13] Fix | Delete
info.insert(1, 'name=%r' % task.get_name())
[14] Fix | Delete
[15] Fix | Delete
coro = coroutines._format_coroutine(task._coro)
[16] Fix | Delete
info.insert(2, f'coro=<{coro}>')
[17] Fix | Delete
[18] Fix | Delete
if task._fut_waiter is not None:
[19] Fix | Delete
info.insert(3, f'wait_for={task._fut_waiter!r}')
[20] Fix | Delete
return info
[21] Fix | Delete
[22] Fix | Delete
[23] Fix | Delete
def _task_get_stack(task, limit):
[24] Fix | Delete
frames = []
[25] Fix | Delete
if hasattr(task._coro, 'cr_frame'):
[26] Fix | Delete
# case 1: 'async def' coroutines
[27] Fix | Delete
f = task._coro.cr_frame
[28] Fix | Delete
elif hasattr(task._coro, 'gi_frame'):
[29] Fix | Delete
# case 2: legacy coroutines
[30] Fix | Delete
f = task._coro.gi_frame
[31] Fix | Delete
elif hasattr(task._coro, 'ag_frame'):
[32] Fix | Delete
# case 3: async generators
[33] Fix | Delete
f = task._coro.ag_frame
[34] Fix | Delete
else:
[35] Fix | Delete
# case 4: unknown objects
[36] Fix | Delete
f = None
[37] Fix | Delete
if f is not None:
[38] Fix | Delete
while f is not None:
[39] Fix | Delete
if limit is not None:
[40] Fix | Delete
if limit <= 0:
[41] Fix | Delete
break
[42] Fix | Delete
limit -= 1
[43] Fix | Delete
frames.append(f)
[44] Fix | Delete
f = f.f_back
[45] Fix | Delete
frames.reverse()
[46] Fix | Delete
elif task._exception is not None:
[47] Fix | Delete
tb = task._exception.__traceback__
[48] Fix | Delete
while tb is not None:
[49] Fix | Delete
if limit is not None:
[50] Fix | Delete
if limit <= 0:
[51] Fix | Delete
break
[52] Fix | Delete
limit -= 1
[53] Fix | Delete
frames.append(tb.tb_frame)
[54] Fix | Delete
tb = tb.tb_next
[55] Fix | Delete
return frames
[56] Fix | Delete
[57] Fix | Delete
[58] Fix | Delete
def _task_print_stack(task, limit, file):
[59] Fix | Delete
extracted_list = []
[60] Fix | Delete
checked = set()
[61] Fix | Delete
for f in task.get_stack(limit=limit):
[62] Fix | Delete
lineno = f.f_lineno
[63] Fix | Delete
co = f.f_code
[64] Fix | Delete
filename = co.co_filename
[65] Fix | Delete
name = co.co_name
[66] Fix | Delete
if filename not in checked:
[67] Fix | Delete
checked.add(filename)
[68] Fix | Delete
linecache.checkcache(filename)
[69] Fix | Delete
line = linecache.getline(filename, lineno, f.f_globals)
[70] Fix | Delete
extracted_list.append((filename, lineno, name, line))
[71] Fix | Delete
[72] Fix | Delete
exc = task._exception
[73] Fix | Delete
if not extracted_list:
[74] Fix | Delete
print(f'No stack for {task!r}', file=file)
[75] Fix | Delete
elif exc is not None:
[76] Fix | Delete
print(f'Traceback for {task!r} (most recent call last):', file=file)
[77] Fix | Delete
else:
[78] Fix | Delete
print(f'Stack for {task!r} (most recent call last):', file=file)
[79] Fix | Delete
[80] Fix | Delete
traceback.print_list(extracted_list, file=file)
[81] Fix | Delete
if exc is not None:
[82] Fix | Delete
for line in traceback.format_exception_only(exc.__class__, exc):
[83] Fix | Delete
print(line, file=file, end='')
[84] Fix | Delete
[85] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function