I have two files:
x.py
class BF(object)
def __init__():
.
.
def add(self,z):
.
.
y.py
from y import BF
def FUNC((a,b,bf))
.
.
bf.add(x)
.
.
return bf
.
.
if __name__ == '__main__':
pool = multiprocessing.Pool(3)
for i in range(len(sl)):
bf_set.append(BF())
results = pool.map(FUNC,zip(sl, itertools.repeat(aa), bf_set))
I also tried to define BF inside FUNC, but sill I got:
PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed
I've read some posts for related issues, but they have their pool.map() inside of the class, so the solutions cannot be applied to this problem (i guess).
Any idea?
I'm going to basically use what you have above, but turn it into working code. There is no problem serializing, if you use
dill
. I'm using a fork ofmultiprocessing
calledpathos.multiprocessing
, which usesdill
instead ofpickle
.This works, because
pathos
usesdill
, which can serialize almost anything in python.Get
pathos
anddill
at: https://github.com/uqfoundation