Repository navigation
Open
Description
The title says it all.
I got this error message :
_pickle.PicklingError: Can't pickle <class 'helper.makeProxy.<locals>.CustomProxy'>: it's not found as helper.makeProxy.<locals>.CustomProxy
when running the code below :
main.py file :
from multiprocess.managers import BaseManager, NamespaceProxy
from helper import makeProxy
class Managed:
pass
class Holder:
def __init__(self, managed):
self.managed = managed
if __name__ == "__main__":
BaseManager.register('M', Managed, makeProxy())
m = BaseManager()
m.start()
managed = m.M()
BaseManager.register('H', Holder, NamespaceProxy)
m = BaseManager()
m.start()
holder = m.H(managed)
helper.py file :
from multiprocess.managers import NamespaceProxy
def makeProxy():
class CustomProxy(NamespaceProxy):
pass
return CustomProxy
I tried different things, and this seems to be the minimal bug case.
- I tried placing the makeProxy method in the main module, and the bug doesn't appear
main.py file :
from multiprocess.managers import BaseManager, NamespaceProxy
class Managed:
pass
class Holder:
def __init__(self, managed):
self.managed = managed
def makeProxy():
class CustomProxy(NamespaceProxy):
pass
return CustomProxy
if __name__ == "__main__":
BaseManager.register('M', Managed, makeProxy())
m = BaseManager()
m.start()
managed = m.M()
BaseManager.register('H', Holder, NamespaceProxy)
m = BaseManager()
m.start()
holder = m.H(managed)
- I tried having the makeProxy method directly return NamespaceProxy, and the bug doesn't appear
helper.py file :
from multiprocess.managers import NamespaceProxy
def makeProxy():
return NamespaceProxy
main.py file as in the bug case
- I tried not passing the Managed instance as attribute of the Holder instance, and the bug doesn't appear
main.py file :
from multiprocess.managers import BaseManager
from helper import makeProxy
class Managed:
pass
class Holder:
pass
if __name__ == "__main__":
BaseManager.register('M', Managed, makeProxy())
m = BaseManager()
m.start()
managed = m.M()
BaseManager.register('H', Holder, NamespaceProxy)
m = BaseManager()
m.start()
holder = m.H()
helper.py file as in the bug case
- I tried having the proxies generated in the managed instances, but not used as proxies for the registration of that manager, and the bug doesn't appear
main.py file :
from multiprocess.managers import BaseManager, NamespaceProxy
from helper import makeProxy
class Managed:
def run(self):
makeProxy()
class Holder:
def __init__(self, managed):
self.managed = managed
def run(self):
makeProxy()
if __name__ == "__main__":
BaseManager.register('M', Managed, NamespaceProxy)
m = BaseManager()
m.start()
managed = m.M()
managed.run()
BaseManager.register('H', Holder, NamespaceProxy)
m = BaseManager()
m.start()
holder = m.H(managed)
holder.run()
helper.py file as in the bug case.
seems to work with any classes inheriting from any proxies available in the managers module, I mainly tested it on NamespaceProxy and ListProxy
Metadata
Metadata
Assignees
Labels
No labels
Activity
malmiteria commentedon Dec 7, 2021
I recently found a simpler version of this bug, using the MakeProxyType from the manager module.
Same bug, but it involves less custom code:
If you're curious about a full traceback, here it is :