Skip to content

Commit

Permalink
ref: create root temp dir for recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 17, 2024
1 parent b42bb56 commit 30a0652
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mpl_data_cast/recipe.py
Expand Up @@ -51,15 +51,14 @@ def __init__(self,
self.path_tar = pathlib.Path(path_tar)
if not self.path_raw.exists():
raise ValueError(f"Raw data path '{self.path_raw}' doesn't exist!")
temp_root = pathlib.Path(tempfile.gettempdir()) / "MPL-Data-Cast"
temp_root.mkdir(exist_ok=True, parents=True)
#: Temporary directory (will be deleted upon application exit)
self.tempdir = pathlib.Path(
# Use the current PID as an identifier for the temp dir
tempfile.mkdtemp(
prefix=f"PID-{os.getpid()}-{self.format}_",
dir=pathlib.Path(tempfile.gettempdir()) / "MPL-Data-Cast"
)
)
self.tempdir.mkdir(exist_ok=True, parents=True)
dir=temp_root))
# Make sure everything is removed in the end.
atexit.register(shutil.rmtree, self.tempdir, ignore_errors=True)

Expand Down

0 comments on commit 30a0652

Please sign in to comment.