Message212934
I am not sure method_to_typeid and create_method were really intended to be public -- they are only used by Pool proxies.
You can maybe work around the problem by registering a second typeid without specifying callable. That can be used in method_to_typeid:
import multiprocessing.managers
class MyClass(object):
def __init__(self):
self._children = {}
def get_child(self, i):
return self._children.setdefault(i, type(self)())
def __repr__(self):
return '<MyClass %r>' % self._children
class MyManager(multiprocessing.managers.BaseManager):
pass
MyManager.register('MyClass', MyClass,
method_to_typeid = {'get_child': '_MyClass'})
MyManager.register('_MyClass',
method_to_typeid = {'get_child': '_MyClass'},
create_method=False)
if __name__ == '__main__':
m = MyManager()
m.start()
try:
a = m.MyClass()
b = a.get_child(1)
c = b.get_child(2)
d = c.get_child(3)
print a # <MyClass {1: <MyClass {2: <MyClass {3: <MyClass {}>}>}>}>
finally:
m.shutdown() |
|
Date |
User |
Action |
Args |
2014-03-08 16:10:32 | sbt | set | recipients:
+ sbt, allista |
2014-03-08 16:10:32 | sbt | set | messageid: <1394295032.28.0.021625958684.issue20854@psf.upfronthosting.co.za> |
2014-03-08 16:10:32 | sbt | link | issue20854 messages |
2014-03-08 16:10:31 | sbt | create | |
|