Skip to main content
`Ctrl`+`K`

# temporary_cache_dir_path

astropy.config.temporary_cache_dir_path(dir_=None, /, *, namespace, suffix=None, prefix=None, delete=True)

  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.TemporaryDirectory` are optionally supported, with a couple differences:

  - `dir` is positional-only and must come first

  - all other arguments are keyword-only

  - `delete` is supported even on Python 3.11

  Added in version 8.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 (see `os.sep`) in the output directory.

  See also

  `temporary_config_dir_path`

    a similar function for configuration directories

  `set_temp_cache`

    a legacy function with similar goals but a much less predictable behavior