You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Manager().dict() garbles __init__() arguments for user-defined type passed as dict value #81
import multiprocess as mp
class UserSet(set):
def __init__(self, y, x):
self.y = y
super().__init__(x)
mngr = mp.Manager()
us = UserSet(22, {23})
dproxy = mngr.dict({'x': us})
The error is
RemoteError:
---------------------------------------------------------------------------
Traceback (most recent call last):
File "~/.pyenv/versions/3.9.1/lib/python3.9/site-packages/multiprocess/managers.py", line 203, in handle_request
request = c.recv()
File "~/.pyenv/versions/3.9.1/lib/python3.9/site-packages/multiprocess/connection.py", line 259, in recv
return _ForkingPickler.loads(buf.getbuffer())
File "~/.pyenv/versions/3.9.1/lib/python3.9/site-packages/dill/_dill.py", line 283, in loads
return load(file, ignore, **kwds)
File "~/.pyenv/versions/3.9.1/lib/python3.9/site-packages/dill/_dill.py", line 278, in load
return Unpickler(file, ignore=ignore, **kwds).load()
File "~/.pyenv/versions/3.9.1/lib/python3.9/site-packages/dill/_dill.py", line 481, in load
obj = StockUnpickler.load(self)
TypeError: __init__() missing 1 required positional argument: 'x'
---------------------------------------------------------------------------
Monkey-patching outside of __init__() works:
import multiprocess as mp
class UserSet(set):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
mngr = mp.Manager()
us = UserSet({23})
us.y = 22
dproxy = mngr.dict({'x':us})
This behavior occurs with mp.__version__ '0.70.11.1' on python 3.8.5 and 3.9.1
FWIW, This is in the context of attaching a lock to each value in the DictProxy.
Activity