From fa7273b328b8cea8b051917f5255a1a712a9e1b9 Mon Sep 17 00:00:00 2001 From: Astounds Date: Sat, 28 Mar 2026 16:06:47 -0500 Subject: fix: race condition in os.makedirs causing worker crashes Replace check-then-create pattern with exist_ok=True to prevent FileExistsError when multiple workers initialize simultaneously. Affects: - subscriptions.py: open_database() - watch.py: save_decrypt_cache() - local_playlist.py: add_to_playlist() - util.py: fetch_url(), get_visitor_data() - settings.py: initialization Fixes Gunicorn worker startup failures in multi-worker deployments. --- settings.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'settings.py') diff --git a/settings.py b/settings.py index 2aecc87..64dbfc5 100644 --- a/settings.py +++ b/settings.py @@ -453,8 +453,7 @@ else: print("Running in non-portable mode") settings_dir = os.path.expanduser(os.path.normpath("~/.yt-local")) data_dir = os.path.expanduser(os.path.normpath("~/.yt-local/data")) - if not os.path.exists(settings_dir): - os.makedirs(settings_dir) + os.makedirs(settings_dir, exist_ok=True) settings_file_path = os.path.join(settings_dir, 'settings.txt') -- cgit v1.2.3