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.
This commit is contained in:
@@ -30,8 +30,7 @@ database_path = os.path.join(settings.data_dir, "subscriptions.sqlite")
|
||||
|
||||
|
||||
def open_database():
|
||||
if not os.path.exists(settings.data_dir):
|
||||
os.makedirs(settings.data_dir)
|
||||
os.makedirs(settings.data_dir, exist_ok=True)
|
||||
connection = sqlite3.connect(database_path, check_same_thread=False)
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user