config_context

function of dascore.config source

config_context(
    new_config: dascore.config.DascoreConfig | None[DascoreConfig, None] = None,
    **kwargs ,
)-> ‘Iterator[DascoreConfig]’

Temporarily override the runtime config for the current thread/task.

Parameters

Parameter Description
new_config A complete DascoreConfig to install.
Mutually exclusive with keyword overrides.
**kwargs Individual field overrides applied on top of the active config.
Note

The override is stored in a ContextVar, so it is isolated per thread and task and restored when the block exits. Whether a newly started OS thread inherits a copy of the override is runtime-dependent (sys.flags.thread_inherit_context – normally enabled on free-threaded builds and disabled otherwise); an inherited copy is not undone by this block’s exit. For deterministic propagation, capture contextvars.copy_context() and run the worker with it, or rely on APIs that bind the config for you such as Spool.map.

Examples

import dascore as dc
with dc.config_context(debug=True):
    assert dc.get_config().debug
assert not dc.get_config().debug