uqfoundation / pathos

parallel graph management and execution in heterogeneous computing
http://pathos.rtfd.io
Other
1.38k stars 89 forks source link

PicklingError: Can't pickle <class 'ctypes.CDLL.__init__.<locals>._FuncPtr'> #163

Open TheCodeSummoner opened 5 years ago

TheCodeSummoner commented 5 years ago

Issue:

The inputs library is causing PicklingError. Code to replicate the error is as follows:

from inputs import devices
from pathos import helpers
Process = helpers.mp.Process

def Foo(d):
    pass

if __name__ == '__main__':
    Process(target=Foo, args=devices).start()

The error raised:

_pickle.PicklingError: Can't pickle <class 'ctypes.CDLL.__init__.<locals>._FuncPtr'>: it's not found as ctypes.CDLL.__init__.<locals>._FuncPtr.

I am unsure which line of inputs code causes it, but there is a following piece of code relevant to the problem in the CDLL class inside ctypes built-in library:

class CDLL(object):
    _FuncPtr = None
        def __init__(self, (...)):
            class _FuncPtr(_CFuncPtr):
                _flags_ = flags
                _restype_ = self._func_restype_
            self._FuncPtr = _FuncPtr

Is it by any chance a lack of dill's support for this type, or more likely an issue with the inputs library? I am using Python 3.6.4.

PS. Thank you for such a quick answer on my question earlier today :)