We're designing an application that is supposed to monitor a system for certain events, email interested parties to prompt them to take action when relevant and parse their replies.
The application is comprised of several threads that handle separate parts (one for monitoring the state and sending emails, another for parsing replies and updating the state etc.).
The flow of the application depends on several flags that we want to serialise periodically and should the application fail, on startup it needs to load those serialised flags or if no serialised file is found, to just initialise them to a default.
How can we best achieve this? We've tinkered with different ideas, such as:
@propertysetters and getters to automatically save/load those flags every time they are requested/modified
having a separate thread that serialises those flags often enough (such as every minute)
have each thread take care of serialising the flags it depends on
What we want to avoid is a case where the system takes some action, sets some flags as a result and then crashes before those modifications are serialised.
We cannot use a database and so we've relied on
cPickle as the serialisation protocol.
Another issue that results from the above problem is whether those flags should be kept centrally in an object or distributed across the different components that rely on them.