Typeerror Cant Pickle _thread



import multiprocessing as mp from functools import partial class Model: def __init__(self): self.a = 1 def process_job(x, y): print('subProcess-a:',y.a) return x if __name__ == '__main__': m = Model() partial_work = partial(process_job, y=m) The custom objects Model # class as a parameter res = pool.map(partial_work, range(5)) # Error will be here pool.close() pool.join() print(res)


import multiprocessing as mp class Model: def __init__(self): self.a = 1 A=None #'Ll need to use in the child of a custom class object declared as global variables def process_job(x): print('subProcess-a:',A.a) # Access Model class object in the child return x if __name__ == '__main__': m = Model() global A A = m # Global variable assignment pool = mp.Pool(5) res = pool.map(process_job, range(5)) # Enable the child process pool.close() pool.join() print(res)