How to change the serialization method used by the multiprocessing module?

前端 未结 1 1576
南旧
南旧 2020-12-03 16:04

How can I change the serialization method used by the Python multiprocessing library? In particular, the default serialization method uses the pickle

相关标签:
1条回答
  • 2020-12-03 16:43

    I believe the patch you're referring to works if you're using a multiprocessing "context" object.

    Using your pickle2reducer.py, your client should start with:

    import pickle2reducer
    import multiprocessing as mp
    
    ctx = mp.get_context()
    ctx.reducer = pickle2reducer.Pickle2Reducer()
    

    And ctx has the same API as multiprocessing.

    Hope that helps!

    0 讨论(0)
提交回复
热议问题