Skip to content

Commit 3d91470

Browse files
committed
Also add the traceback for Tasks
1 parent bc1e1d3 commit 3d91470

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/payloads/dump_heap.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __payload_entrypoint(output_path: str) -> None:
1212

1313
logging.warning("XXX: dump_heap: writing report to %r", output_path)
1414
logging.warning("XXX: dump_heap: collecting gc")
15-
gc.collect()
15+
gc.collect(0)
1616
gc.collect(1)
1717
gc.collect(2)
1818
seen: set[int] = set()
@@ -213,7 +213,15 @@ def _get_payload(obj: Any) -> bytes | None:
213213
payload = b",".join(payload_entries)
214214
del payload_entries
215215
elif isinstance(obj, asyncio.Task):
216+
max_payload_size = 4096
216217
payload_str = obj.get_name()
218+
# The important bits in the stack frames are always towards at
219+
# the bottom. So we revert it for simplicity.
220+
source_traceback = obj._source_traceback # type: ignore[attr-defined]
221+
if source_traceback is not None:
222+
payload_str += "\n" + "\n".join(
223+
repr(frame) for frame in source_traceback[::-1]
224+
)
217225
elif isinstance(obj, asyncio.events.Handle):
218226
max_payload_size = 4096
219227
# The important bits in the stack frames are always towards at

0 commit comments

Comments
 (0)