Attribute Sharing Within A Class Using Multiprocessing
I have a class that has a dictionary as attribute. In this class, I run multiprocessing to fill up a Queue and then use additional process to perform some calculations on items tha
Solution 1:
Remember these are running as two separate processes. They do not share memory. Each one has its own copy of the RNG instance, and will not see changes made by the other. If you need to communicate between them, you need to use a Queue or a Pipe.
Often, what multiprocessing apps to is establish a "command" object to pass between them. The command has some kind of verb, plus data to be acted on. So, when you want to add a key, you could send ('add','even') or something like that. Your queue handler can then do several different kinds of things.
Post a Comment for "Attribute Sharing Within A Class Using Multiprocessing"