From c7dc9cf3c0ce0e38b8bb3deb2455c379c171f74d Mon Sep 17 00:00:00 2001 From: awohns Date: Tue, 16 Feb 2021 00:31:17 +0000 Subject: [PATCH] fix race condition, again --- tsdate/cache.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tsdate/cache.py b/tsdate/cache.py index 81bf9b5b..e328da7a 100644 --- a/tsdate/cache.py +++ b/tsdate/cache.py @@ -52,7 +52,9 @@ def get_cache_dir(): precalculated data. """ cache_dir = pathlib.Path(appdirs.user_cache_dir("tsdate", "tsdate")) - if not os.path.exists(cache_dir): - logger.info(f"Set cache_dir to {cache_dir}") + try: os.makedirs(cache_dir) + logger.info(f"Set cache_dir to {cache_dir}") + except OSError: + logger.info(f"{cache_dir} already exists") return cache_dir