share dictionary between processes

Wolodja Wentland wentland at cl.uni-heidelberg.de
Fri Dec 18 09:20:42 EST 2009


On Thu, Dec 17, 2009 at 23:48 -0800, blumenkraft wrote:
> I want to share dictionary between two distinct processes.
> Something like this:
> 
> first.py
> import magic_share_module
> def create_dictionary():
>     return {"a": 1}
> 
> magic_share_module.share("shared_dictionary",
> creator.create_dictionary)
> while True:
>      pass

Have a look at multiprocessing.Manager() it provides (among other
things) proxies for dictionaries that can be used in different threads.
These are even accessible on different hosts if configures correctly.
-- 
  .''`.     Wolodja Wentland    <wentland at cl.uni-heidelberg.de> 
 : :'  :    
 `. `'`     4096R/CAF14EFC 
   `-       081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20091218/d5de0041/attachment.sig>


More information about the Python-list mailing list