remove_temp_dir
FunctionPrivateSource
remove_temp_dir(path: str | os.PathLike)
Remove the temporary directory.
Note that this method only works if it is called by the main process.
The exception caused by file occupation is suppressed.
Arguments
Requires
Argument | Type | Required | |
---|---|---|---|
path | str | os.PathLike | The path of the directory to be removed. |
Examples
Remove a folder
- Codes
- Results
import os
import multiprocessing as mproc
from dash_file_cache.utilities import remove_temp_dir
os.makedirs("temp-folder1", exists_ok=True)
os.makedirs("temp-folder2", exists_ok=True)
remove_temp_dir("temp-folder1")
p = mproc.Process(target=remove_temp_dir, args=("temp_folder2",))
p.start()
p.join()
- The folder
"temp-folder1"
is created but removed, so it will not exist. - The folder
"temp-folder2"
is not removed in the sub-process, so it will exist.