tracemalloc.Filter

class tracemalloc.Filter(inclusive: bool, filename_pattern: str, lineno: int=None, all_frames: bool=False)

Filter on traces of memory blocks.

See the fnmatch.fnmatch() function for the syntax of filename_pattern. The '.pyc' file extension is replaced with '.py'.

Examples:

  • Filter(True, subprocess.__file__) only includes traces of the subprocess module
  • Filter(False, tracemalloc.__file__) excludes traces of the tracemalloc module
  • Filter(False, "<unknown>") excludes empty tracebacks

Changed in version 3.5: The '.pyo' file extension is no longer replaced with '.py'.

inclusive

If inclusive is True (include), only trace memory blocks allocated in a file with a name matching filename_pattern at line number lineno.

If inclusive is False (exclude), ignore memory blocks allocated in a file with a name matching filename_pattern at line number lineno.

lineno

Line number (int) of the filter. If lineno is None, the filter matches any line number.

filename_pattern

Filename pattern of the filter (str).

all_frames

If all_frames is True, all frames of the traceback are checked. If all_frames is False, only the most recent frame is checked.

This attribute has no effect if the traceback limit is 1. See the get_traceback_limit() function and Snapshot.traceback_limit attribute.

doc_python
2016-10-07 17:45:14
Comments
Leave a Comment

Please login to continue.