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

后端 未结 12 1795
醉梦人生
醉梦人生 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:05

    A potentially trivial solution to this is to switch to using multiprocessing.dummy. This is a thread based implementation of the multiprocessing interface that doesn't seem to have this problem in Python 2.7. I don't have a lot of experience here, but this quick import change allowed me to call apply_async on a class method.

    A few good resources on multiprocessing.dummy:

    https://docs.python.org/2/library/multiprocessing.html#module-multiprocessing.dummy

    http://chriskiehl.com/article/parallelism-in-one-line/

提交回复
热议问题