EnvironmentState#
- class brainstate.environ.EnvironmentState(settings=<factory>, contexts=<factory>, functions=<factory>, locks=<factory>)[source]#
Thread-local storage for environment configuration.
This class maintains separate configuration states for different threads, ensuring thread-safe environment management in concurrent applications.
- contexts#
Stack of context-specific settings for nested contexts.
- Type:
defaultdict[Hashable, List[Any]]
- functions#
Registered callback functions for environment changes.
- Type:
Dict[Hashable, Callable]
- locks#
Reentrant thread locks for synchronized access to critical sections. These must be reentrant:
context()holds a key’s lock across its restore path while callingget(), which re-acquires the same lock.- Type:
Dict[str, threading.RLock]