yera.apps.context
Per-invocation app context, accessible via a ContextVar.
The @app decorator pushes an
AppContext onto a stack on
entry and pops it on exit; user code reads the current context via
get_app_context.
Symbols
AppContext
Per-invocation runtime context for an executing app.
Pushed onto a ContextVar stack on entry and popped on exit.
Tracks the app's metadata, an instance counter, and its position
in the app stack (top-level vs. nested). Managed by the
@app decorator; not constructed
by user code.
Attributes
AppMetadata
describing the app this context belongs to.
Counter for this app's invocations within a single run.
Methods
AppContext.__enter__
__enter__()Push this context onto the stack and return it.
AppContext.__exit__
__exit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
)Pop this context off the stack.
AppContext.top_level
top_level() → boolReturn whether this context is the outermost app on the stack.
Raises
If called before the context has been entered.
get_app_context
get_app_context() → AppContextReturn the currently executing app's runtime context.
For framework code that needs to inspect the running app (e.g. its metadata or position in the app stack). User code in an app's body rarely needs this.
Returns
The active AppContext.
Raises
If called outside an active app invocation.
no_active_app_context
no_active_app_context() → boolReturn True if no app context is currently active.