I have a Python application where I create several objects that spawn one or more multiprocessing.Process objects. I want to create an object that these processes can access which will allow them to retrieve and save key/value pairs from a file. I also want the ability for a processes to be able to access key/value pairs that other processes have saved. The application is running in an environment where I only want writes to occur at specific times which are controlled by the parent process.
My initial idea was to create a singleton wrapper containing a dictionary which would load values upon instantiation and write to a file when directed to do so. I quickly found out that this just lead to a singleton that was created for every process which had no knowledge of any value generated since the last time any process saved values to a file.
Is there a way to implement the dictionary in the singleton that would be shared between processes without having to explicitly pass the dictionary into the constructor of the multiprocessing.Process object? I'm also open to alternative solutions (i.e. not use a singleton).