Handling the classmethod pickling issue with copy_reg

前端 未结 3 1580
花落未央
花落未央 2021-02-04 14:17

I met a pickling error when dealing with multiprocessing:

 from multiprocessing import Pool

 def test_func(x):
     return x**2

 class Test:
     @classmethod
         


        
3条回答
  •  佛祖请我去吃肉
    2021-02-04 14:49

    Instead of returning the actual class object from _pickle_method, return a string that can be used to import it when unpickling and then do that in _unpickle_method

提交回复
热议问题