Can't pickle when using multiprocessing Pool.map()

后端 未结 12 1768
醉梦人生
醉梦人生 2020-11-22 00:19

I\'m trying to use multiprocessing\'s Pool.map() function to divide out work simultaneously. When I use the following code, it works fine:

12条回答
  •  旧巷少年郎
    2020-11-22 01:06

    Update: as of the day of this writing, namedTuples are pickable (starting with python 2.7)

    The issue here is the child processes aren't able to import the class of the object -in this case, the class P-, in the case of a multi-model project the Class P should be importable anywhere the child process get used

    a quick workaround is to make it importable by affecting it to globals()

    globals()["P"] = P
    

提交回复
热议问题