python singleton into multiprocessing

前端 未结 5 746
时光取名叫无心
时光取名叫无心 2021-01-13 02:53

How can I code to share the same instance of a \"singletonic\" class among processes?

5条回答
  •  天涯浪人
    2021-01-13 03:50

    In Python 2.6 the multiprocessing module has a Value object used for sharing state between processes. They have a code sample that should give you an idea of how to share state in this manner, and you can use this approach when writing a singleton class.

提交回复
热议问题