How to synchronize a python dict with multiprocessing

前端 未结 4 1136
执念已碎
执念已碎 2020-12-02 09:28

I am using Python 2.6 and the multiprocessing module for multi-threading. Now I would like to have a synchronized dict (where the only atomic operation I really need is the

4条回答
  •  清歌不尽
    2020-12-02 10:04

    Is there a reason that the dictionary needs to be shared in the first place? Could you have each thread maintain their own instance of a dictionary and either merge at the end of the thread processing or periodically use a call-back to merge copies of the individual thread dictionaries together?

    I don't know exactly what you are doing, so keep in my that my written plan may not work verbatim. What I'm suggesting is more of a high-level design idea.

提交回复
热议问题