I have a list (called requestRoster) containing dictionaries (called requests). Items in the 'requests' dictionary are things like 'requestTime' and 'thisURL'. E.g.:
[
{'thisURL': 'http://localhost/bikes', 'requestTime': datetime.datetime(2012, 10, 18, 0, 41, 34)},
{'thisURL': 'http://localhost/clothing', 'requestTime': datetime.datetime(2012, 10, 18, 0, 41, 35)}
]
I am using multiprocessing.Process to spawn a new process to issue each request.
I would like each process to update the requestRoster, adding a 'response' item to each request.
How can I do this?
I have tried using a multiprocessing.Manager() to make a manager.list() and a manager.Namespace(). Neither lets me do what I want to do, I think because of this: http://docs.python.org/library/multiprocessing.html#multiprocessing.managers.SyncManager.list
I think I could use a multiprocessing.Lock() to
- acquire a mutex
- make a copy of the requestRoster inside the process
- modify the localised requestRoster
- overwrite the 'globablised' request roster with the localised one
- release the mutex
... but it seems a bit elaborate and I wonder if I'm missing something simpler. An asynchronous callback would be great.