DiffSK / configobj

Python 3+ compatible port of the configobj library
https://configobj.readthedocs.org
Other
321 stars 76 forks source link

Make write atomic #180

Open ctoth opened 5 years ago

ctoth commented 5 years ago

Currently if you call write, it directly calls write on the underlying file object. If then the power fails or the process crashes the file is left in a garbage state. I recommend writing to a temporary file, then using rename as this is the accepted practice for atomic writes.

Alternatively you could depend on https://github.com/untitaker/python-atomicwrites

Let me know which approach you prefer and I will open a PR implementing it.

robdennis commented 1 year ago

Thanks for offering to make a PR for this, though clearly this is 4 years late. I don't feel up to this being in 5.1.0, but seems like a good idea.

If this comes back around, I'd prefer the temp file appraoch.