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:
@@ -329,11 +329,8 @@ def get_ordered_music_list_attributes(music_list):
|
||||
|
||||
|
||||
def save_decrypt_cache():
|
||||
try:
|
||||
f = open(os.path.join(settings.data_dir, 'decrypt_function_cache.json'), 'w')
|
||||
except FileNotFoundError:
|
||||
os.makedirs(settings.data_dir)
|
||||
f = open(os.path.join(settings.data_dir, 'decrypt_function_cache.json'), 'w')
|
||||
os.makedirs(settings.data_dir, exist_ok=True)
|
||||
f = open(os.path.join(settings.data_dir, 'decrypt_function_cache.json'), 'w')
|
||||
|
||||
f.write(json.dumps({'version': 1, 'decrypt_cache':decrypt_cache}, indent=4, sort_keys=True))
|
||||
f.close()
|
||||
|
||||
Reference in New Issue
Block a user