What would be the best way to handle lightweight crash recovery for my program?
I have a Python program that runs a number of test cases and the results are stored in a dictionary which serves as a cache. If I could save (and then restore) each item that is added to the dictionary, I could simply run the program again and the caching would provide suitable crash recovery.
- You may assume that the keys and values in the dictionary are easily convertible to strings ie. using either str or the pickle module.
- I want this to be completely cross platform - well at least as cross platform as Python is
- I don't want to simply write out each value to a file and load it in my program might crash while I am writing the file
- UPDATE: This is intended to be a lightweight module so a DBMS is out of the question.
- UPDATE: Alex is correct in that I don't actually need to protect against crashes while writing out, but there are circumstances where I would like to be able to manually terminate it in a recoverable state.
- UPDATE Added a highly limited solution using standard input below