tracemalloc.Traceback

class tracemalloc.Traceback

Sequence of Frame instances sorted from the most recent frame to the oldest frame.

A traceback contains at least 1 frame. If the tracemalloc module failed to get a frame, the filename "<unknown>" at line number 0 is used.

When a snapshot is taken, tracebacks of traces are limited to get_traceback_limit() frames. See the take_snapshot() function.

The Trace.traceback attribute is an instance of Traceback instance.

format(limit=None)

Format the traceback as a list of lines with newlines. Use the linecache module to retrieve lines from the source code. If limit is set, only format the limit most recent frames.

Similar to the traceback.format_tb() function, except that format() does not include newlines.

Example:

print("Traceback (most recent call first):")
for line in traceback:
    print(line)

Output:

Traceback (most recent call first):
  File "test.py", line 9
    obj = Object()
  File "test.py", line 12
    tb = tracemalloc.get_object_traceback(f())
doc_python
2016-10-07 17:45:20
Comments
Leave a Comment

Please login to continue.