context_propagation¶
Intro¶
Because protoprimer already needs some config to run (see derived_config),
it can be reused by other scripts.
To reuse config, scripts rely on the same bootstrap mechanism to traverse and load it via conf_leap. This requires an abs path to proto_code.
At the same time, due to context_isolation,
PROTOPRIMER_PROTO_CODE env var is removed before passing control to any client code.
This is correct as env vars leak to child processes
(and PROTOPRIMER_PROTO_CODE will unintentionally affect any other protoprimer code started subsequently).
To pass the knowledge of the proto_code abs path to
the client script without affecting its child processes,
protoprimer sets a global variable accessible via protoprimer.primer_kernel.get_proto_kernel_abs_path
that can be used for any protoprimer (or metaprimer) API.
For EntryFunc.func_call_lib (e.g., get_config), EnvContext._proto_kernel_abs_path can override
the global - when set, the bootstrapper uses it instead of the global variable.
See also¶
This feature provides support to lib_access_to_config_data.