Return a tabular representation of tracked objects
(ignore: Any = NoneType)
| 48 | |
| 49 | # using Any as it's hard to type type(None) |
| 50 | def 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 | |
| 64 | def print_live_refs(*a: Any, **kw: Any) -> None: |
no test coverage detected