pytc.xtc.issue_stage_stats_scope

pytc.xtc.issue_stage_stats_scope()[source]

Establish a per-pipeline accumulator for _accum_issue_stage.

Yields a dict that subsequent _accum_issue_stage calls will mutate. The accumulator is process-wide (visible from all threads) so that the per-device issue worker threads spawned by _round_robin_pipeline can read it; threading.local would isolate the parent’s scope from the workers and lose every timer.

Concurrency contract

Only ONE pipeline-level scope may be active at a time. Two pipelines running concurrently on different threads would both overwrite _ISSUE_STAGE_STATS["current"] and silently mix / lose timer attribution. The scheduler is single-pipeline today so this never happens in practice, but the contract is enforced explicitly here to fail fast if a future caller violates it.

Nested scopes from the SAME thread are allowed — the outer scope is restored on __exit__ — so it’s safe for the scheduler to enter a scope even if a callee under the same thread might also enter one.