Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manager().dict() garbles __init__() arguments for user-defined type passed as dict value #81

Open
eric-downes opened this issue Mar 20, 2021 · 0 comments

Comments

@eric-downes
Copy link

The following code fails

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant