From adbb988b2f2f75c002adfe5a5c251e55c335c392 Mon Sep 17 00:00:00 2001 From: midaa1 Date: Mon, 2 Mar 2026 12:12:50 +0200 Subject: [PATCH] fixing race condition problem --- app/routes/session.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/routes/session.py b/app/routes/session.py index 1db18593..fd6d0ea7 100644 --- a/app/routes/session.py +++ b/app/routes/session.py @@ -6,7 +6,7 @@ import csv import math import numpy as np - +import uuid from pathlib import Path import os import pandas as pd @@ -24,6 +24,7 @@ # Constants + ALLOWED_EXTENSIONS = {"txt", "webm"} COLLECTION_NAME = "session" @@ -162,7 +163,7 @@ def batch_predict(): base_path = Path().absolute() / "app/services/calib_validation/csv/data" calib_csv_path = base_path / f"{calib_id}_fixed_train_data.csv" - predict_csv_path = base_path / "temp_batch_predict.csv" + predict_csv_path = base_path / f"temp_batch_predict_{uuid.uuid4().hex}.csv" # CSV temporário with open(predict_csv_path, "w", newline="") as csvfile: @@ -187,7 +188,8 @@ def batch_predict(): screen_width=screen_width, screen_height=screen_height, ) - + os.remove(predict_csv_path) + return jsonify(convert_nan_to_none(result)) except Exception as e: