How to share a string amongst multiple processes using Managers() in Python?

后端 未结 2 1388
心在旅途
心在旅途 2020-12-29 07:10

I need to read strings written by multiprocessing.Process instances from the main process. I already use Managers and queues to pass arguments to processes, so using the Man

2条回答
  •  轮回少年
    2020-12-29 07:38

    Simply put the string in a dict:

    d = manager.dict()
    d['state'] = 'xyz'
    

    As strings themselves are immutable, sharing one directly would not be as useful.

提交回复
热议问题