configure
configure
#
The active scratch: a process-wide default, or one scoped to the current context.
Every process on a machine shares one scratch unless told otherwise:
default_root is CG_SCRATCH when set, else ~/.cache/capturegraph.
configure installs the default every thread shares (an explicit path, else
default_root); temporary overrides it for one with block in the
calling thread or task only, so a throwaway scratch in one worker never
redirects another.
scoped_scratch = ContextVar('cg_scoped_scratch', default=None)
module-attribute
#
The scratch overriding the default in the current context, if any.
active_scratch()
#
The scratch in effect: the context's override, else the default, opened on first use.
Source code in capturegraph-lib/capturegraph/scratch/configure.py
configure(path=None, *, max_size_gb=None, free_space_ratio=None)
#
Open (or initialize) the process-wide default scratch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path | None
|
The scratch root. Defaults to |
None
|
max_size_gb
|
float | None
|
Hard cap on the cache's byte budget, in gigabytes. |
None
|
free_space_ratio
|
float | None
|
Fraction of releasable disk the cache may claim. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The configured scratch's root directory. |
Source code in capturegraph-lib/capturegraph/scratch/configure.py
current_scratch()
#
default_root()
#
The scratch every process shares: CG_SCRATCH when set, else ~/.cache/capturegraph.