I'm trying to share an object between 2 processes on two different computers using the Python multiprocessing
module.
The problem is that the object never seems to be reflected correctly in the processes.
Referring to the documentation
https://docs.python.org/2.7/library/multiprocessing.html#multiprocessing.managers.SyncManager
and
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.managers.Namespace
I believe this will create an object that is shared between the two clients but this doesn't seem to be the case
class BosunManager(SyncManager):
def __init__(self, server=True, **kwargs):
# () -> None
super(BosunManager, self).__init__(**kwargs)
def register_functions(self):
self.x = self.Namespace()
Server Starting program
bosun_manager = BosunManager(address=('', 50020), authkey='abracadabra')
bosun_manager.start()
bosun_manager.register_functions()
Client Program #1
from bosun.multi_process_manager import BosunManager
bm = BosunManager(server=False, address=('', 50020), authkey='abracadabra')
bm.connect()
bm.register_functions()
bm.x.x =10 # <---- SETTING X HERE
Client Program #2
from bosun.multi_process_manager import BosunManager
bm = BosunManager(server=False, address=('', 50020), authkey='abracadabra')
bm.connect()
bm.register_functions()
print bm.x.x
However Client #2 always shows an AttributeError for the print bm.x.x
line