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. --- youtube/local_playlist.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'youtube/local_playlist.py') diff --git a/youtube/local_playlist.py b/youtube/local_playlist.py index aa3ac27..968f1a6 100644 --- a/youtube/local_playlist.py +++ b/youtube/local_playlist.py @@ -26,8 +26,7 @@ def video_ids_in_playlist(name): def add_to_playlist(name, video_info_list): - if not os.path.exists(playlists_directory): - os.makedirs(playlists_directory) + os.makedirs(playlists_directory, exist_ok=True) ids = video_ids_in_playlist(name) missing_thumbnails = [] with open(os.path.join(playlists_directory, name + ".txt"), "a", encoding='utf-8') as file: -- cgit v1.2.3