-
Notifications
You must be signed in to change notification settings - Fork 61
ensure atomic writes when saving a file #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fc9ba2f
to
187e064
Compare
2b06b62
to
82a300b
Compare
Maybe adding a |
Maybe that is also worth investigating as a separate issue? Saving usually shouldn't cause a problem if adaptive is stable. |
The implementation is rather fragile and potentially hitting bad corner cases (overwriting a different file, times being messed up, etc); I think there should be a more systematic way to do an atomic write. |
The reason for the crash is not Adaptive, but merely low priority nodes that can be evicted at any time, that suddenly stop. |
Do you have a suggestion? |
https://github.com/untitaker/python-atomicwrites seems like an option or any other alternatives. Or we could use all the relevant tricks from it. |
I also have to bring up another approach: we provide a way to get an in-memory data in adaptive and the user uses |
9a45665
to
015c436
Compare
There is already I do not mind to add the dependency, it's used by 19723 other packages and it is tiny. See the commit I've made. Also, I don't see a reason why people wouldn't want a 'safe' save. |
2115f48
to
0cc2fc7
Compare
Right now, if a program crashes in the middle of saving, you lose all your data. Right now, if a program crashes in the middle of saving, you lose all your data. This ensures that the old file is first moved, then the new file is saved, and only then the old file is removed.
Right now, if a program crashes in the middle of saving, you lose all your data. This ensures that the old file is first moved, then the new file is saved, and only then the old file is removed.
This is not a hypothetical scenario but happens every day for some people that I work with ATM.