python singleton into multiprocessing

前端 未结 5 707
时光取名叫无心
时光取名叫无心 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:31

    Best is to designate one specific process as owning that instance and dedicated to it; any other process requiring access to that instance obtains it by sending messages to the owning process via a Queue (as supplied by the multiprocessing module) or other IPC mechanisms for message passing, and gets answers back via similar mechanisms.

提交回复
热议问题