temporary_cache_dir_path#
- astropy.config.temporary_cache_dir_path(dir_=None, /, *, namespace, suffix=None, prefix=None, delete=True)[source]#
A context manager to create a temporary directory and define it as the cache directory associated with some namespace.
The directory returned will shadow both ASTROPY_CACHE_DIR and XDG_CACHE_HOME environment variable if defined.
This may also be used as a decorator on a function to set the cache path just within that function.
Thread safety is guaranteed, but concurrency isn’t: only a single thread at a time may execute code within this context.
All arguments from
tempfile.TemporaryDirectoryare optionally supported, with a couple differences:diris positional-only and must come firstall other arguments are keyword-only
deleteis supported even on Python 3.11
Added in version 8.0.0.
- Parameters:
- namespace
python:str, keyword-only A mandatory unique identifier for the namespace associated to a temporary directory, which will used to name the directory itself. This string must be non-empty, and can only contain alphanumeric characters,
_,-or...is special cased to represent a path separator (seeos.sep) in the output directory.
- namespace
See also
temporary_config_dir_patha similar function for configuration directories
set_temp_cachea legacy function with similar goals but a much less predictable behavior