Saturday, 15 May 2010

python 2.7 - share dict between processes -


I'm creating a different process to handle my cloud services. I like it:

  CldProc = Process (target = CloudRun) CldProc.start ()   

And wondering if I shared a common dictionary between CloudProx and my current main process ?

Edit: Alternatively, I am thinking of dumping my data from a process to a file and using pickle to load it, its To use the process to complete the process and wait for the exit ().

2 ADIT So, now I have been declared my word like mac_dict = {} and then I fill it my sub process and want to access it in my main process now I tried this:

  & gt; & Gt; & Gt; Dict = dict ()> gt; & Gt; & Gt; Dict ['A'] = 1> & gt; & Gt; & Gt; Print Dict {'A': 1}   

So how does Python know that dict should be called from the manager? Is there an example that I can follow?

Got it, to simplify, I did this:

  With multiprocessing import process, Manager def myf (myd): myd [1] = "Hello World!" Def proc (d): myf (d) m = Manager () locdict = m.dict () locdict [2] = "HI Buddy!" P = Process (target = proc, args = (censure,)) p.start () p.join () Print Rule    

No comments:

Post a Comment