MCPcopy
hub / github.com/scrapy/scrapy / format_live_refs

Function format_live_refs

scrapy/utils/trackref.py:50–61  ·  view source on GitHub ↗

Return a tabular representation of tracked objects

(ignore: Any = NoneType)

Source from the content-addressed store, hash-verified

48
49# using Any as it's hard to type type(None)
50def format_live_refs(ignore: Any = NoneType) -> str:
51 """Return a tabular representation of tracked objects"""
52 s = "Live References\n\n"
53 now_ns = monotonic_ns()
54 for cls, wdict in sorted(live_refs.items(), key=lambda x: x[0].__name__):
55 if not wdict:
56 continue
57 if issubclass(cls, ignore):
58 continue
59 oldest_ns = min(wdict.values())
60 s += f"{cls.__name__:<30} {len(wdict):6} oldest: {int((now_ns - oldest_ns) // 1e9)}s ago\n"
61 return s
62
63
64def print_live_refs(*a: Any, **kw: Any) -> None:

Callers 2

dump_stacktraceMethod · 0.90
print_live_refsFunction · 0.85

Calls 2

itemsMethod · 0.80
valuesMethod · 0.80

Tested by

no test coverage detected