globals¶
globals
¶
Process-wide caches shared by every Tracer.
Tracing a with block means finding its source, parsing it to an AST, and
compiling the block body — work that is identical every time the same block is
entered. These two module-level dicts memoize that work across all tracer
instances so, e.g., a with model.trace(...) inside a Python loop is read,
parsed, and compiled exactly once.
Both grow with the number of distinct source files and trace sites seen during
the process, which is bounded by the program's own source, so they are never
evicted. Neither is re-validated against on-disk changes: a source edited
mid-run is still traced as it was first seen (see Tracer.source).
A process that builds blocks it receives — a server — runs other programs'
source, so it confines each build to itself with block_scope.
BLOCKS
module-attribute
¶
block_scope
¶
Undo, on exit, what building a received block added to these caches and linecache.
RequestModel.deserialize
registers a block's source in linecache under the client's filename, and
the invokes inside it are parsed from there and memoized here under that
filename. Kept, a later request from the same file is parsed against its
predecessor's block — running the old invoke body, or finding no with at
its line — and on a long-lived server all three grow with every client file
seen.
The restore undoes whatever else registered meanwhile, so builds under it must not interleave.