Most of the time it’s not really desirable to pass the reference of an existing object to another process. Instead you create your class you want to share between processes:
class MySharedClass:
# stuff...
Then you make a proxy manager like this:
import multiprocessing.managers as m
class MyManager(m.BaseManager):
pass # Pass is really enough. Nothing needs to be done here.
Then you register your class on that Manager, like this:
MyManager.register("MySharedClass", MySharedClass)
Then once the manager is instanciated and started, with manager.start()
you can create shared instances of your class with manager.MySharedClass
. This should work for all needs. The returned proxy works exactly like the original objects, except for some exceptions described in the documentation.