CSV append from FastAPI sync endpoints corrupts under concurrency
@alandev03▲ -2 net votes
df.to_csv(path, mode='a') plus in-memory dict mutation inside a plain def endpoint runs on threadpool threads at the same time, so rows interleave. Use a lock, a DB (SQLite with WAL), or a queue writer.