Skip to content

Fixed race condition in batch_predict()#88

Open
ChaitanyaChute wants to merge 1 commit intoruxailab:mainfrom
ChaitanyaChute:fix/concurrent-batch-predict-temp-file
Open

Fixed race condition in batch_predict()#88
ChaitanyaChute wants to merge 1 commit intoruxailab:mainfrom
ChaitanyaChute:fix/concurrent-batch-predict-temp-file

Conversation

@ChaitanyaChute
Copy link
Copy Markdown

Fixes Issue #82

Summary

Fixes a race condition where concurrent batch_predict() requests overwrite the same temp_batch_predict.csv file.

  • Generate unique temp filenames using uuid4()
  • Add cleanup in a finally block to prevent leftover temp files

Problem

In app/routes/session.py:165, all POST /batch_predict requests write to:

temp_batch_predict.csv

Concurrent requests overwrite each other's data, causing incorrect or corrupted predictions.

Changes

  • Added import uuid
  • Changed temp filename to:
temp_batch_predict_{uuid4}.csv
  • Wrapped logic in try/finally to ensure temp file cleanup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant