Skip to main content
Version: 1.0.0 (latest)

common.configuration.container

Container Objects

class Container()

[view_source]

A singleton injection container holding several injection contexts. Implements basic dictionary interface.

Injection context is identified by its type and available via dict indexer. The common pattern is to instantiate default context value if it is not yet present in container.

By default, the context is thread-affine so it can be injected only n the thread that originally set it. This behavior may be changed in particular context type (spec).

The indexer is settable and allows to explicitly set the value. This is required by in any context that needs to be explicitly instantiated.

The injectable_context allows to set a context with a with keyword and then restore the previous one after it gets out of scope.

thread_contexts

A thread aware mapping of injection context

main_context

Injection context for the main thread

injectable_context

@contextmanager
def injectable_context(config: TConfiguration,
lock_context: bool = False) -> Iterator[TConfiguration]

[view_source]

A context manager that will insert config into the container and restore the previous value when it gets out of scope.

thread_pool_prefix

@staticmethod
def thread_pool_prefix() -> str

[view_source]

Creates a container friendly pool prefix that contains starting thread id. Container implementation will automatically use it for any thread-affine contexts instead of using id of the pool thread

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.