Configuration attributes

Behavior that applies to a whole tracer is set with class-level attributes on your BaseTracer subclass. Set them in the class body:

class CoverageTracer(pyc.BaseTracer):
    bytecode_caching_allowed = False
    # ... handlers ...

Attribute

Default

Effect

instrument_all_files

False

Instrument every imported file, ignoring should_instrument_file().

allow_reentrant_events

False

Allow handlers to fire while another event is already being handled. Needed by macro-style tracers (see quasiquote); can also be entered locally with pyccolo.allow_reentrant_event_handling().

multiple_threads_allowed

False

Emit events from threads other than the one that entered the tracing context.

requires_ast_bookkeeping

True

Retain the AST bookkeeping tables (node-by-id, parent links, augmentations). Turn off only if no handler needs resolved nodes.

should_patch_meta_path

True

Install the sys.meta_path import hook when tracing, so imports can be instrumented.

global_guards_enabled

True

Enable the global guard machinery. Purely transformational tracers (that only rewrite syntax) set this False so they compose cleanly.

bytecode_caching_allowed

True

Allow cached instrumented bytecode. Coverage-style tracers set this False to avoid stale/omitted statements.

instrument_lambdas

False

Let instrumented() weave bare lambda\ s (lifted into synthetic def\ s).

keep_sandbox_source

False

Register pre-instrumentation source in linecache so inspect.getsource() and tracebacks work for exec/eval-compiled code.

ast_rewriter_cls

AstRewriter

The rewriter class to use; override to customize the transform.

See also

The overridable methods (should_instrument_file and friends) are on the BaseTracer reference; Why composing tracers works explains why transformational tracers set global_guards_enabled = False.