Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'x-mailer:apple mail (2.936)': 0.03; 'skip:# 20': 0.03; 'filename:fname piece:py': 0.04; 'sys': 0.04; 'value,': 0.04; 'main()': 0.05; 'warnings': 0.05; '__name__': 0.07; 'dictionary': 0.07; '"__main__":': 0.09; 'received:172.16.0': 0.09; 'def': 0.13; 'result.': 0.14; '[[]': 0.16; 'dictionaries': 0.16; 'key)': 0.16; 'main():': 0.16; 'res': 0.16; 'thanks,': 0.17; 'skip:r 30': 0.19; 'code': 0.22; 'trying': 0.23; 'example': 0.24; 'correct': 0.26; 'arrays': 0.31; 'received:155': 0.31; 'does': 0.31; 'all,': 0.31; 'import': 0.32; 'to:addr:python-list': 0.32; 'from:charset:iso-8859-1': 0.33; 'received:172.16': 0.35; 'print': 0.35; 'received:es': 0.35; 'subject:with': 0.37; 'but': 0.38; 'current': 0.38; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'works': 0.40; 'results': 0.61; 'header:Message-Id:1': 0.62; 'show': 0.67; 'share': 0.67; 'subject:Manager': 0.84 From: =?ISO-8859-1?Q?Dar=EDo_Su=E1rez_Gracia?= To: python-list@python.org Content-Type: multipart/mixed; boundary=Apple-Mail-15-824396897 Mime-Version: 1.0 (Apple Message framework v936) Subject: shared dictionary of dictionaries with Manager Date: Thu, 21 Apr 2011 18:00:27 +0200 X-Mailer: Apple Mail (2.936) X-Mail-Scanned: Criba 2.0 + Clamd & Bogofilter X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 62 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303403386 news.xs4all.nl 41113 [::ffff:82.94.164.166]:51586 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3808 --Apple-Mail-15-824396897 Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Hi all, I was trying to share a dictionary of dictionaries of arrays with =20 Manager from multiprocessing. Without multiprocessing the code works =20 perfectly, but with the current example the last print does not show =20 the correct result. Any hint? Thanks, Dar=EDo Su=E1rez= --Apple-Mail-15-824396897 Content-Disposition: attachment; filename=test_dict_dict_arrays.py Content-Type: text/x-python-script; x-unix-mode=0644; name="test_dict_dict_arrays.py" Content-Transfer-Encoding: 7bit #!/usr/local/bin/python2.7 import sys import warnings from multiprocessing import Pool, Value, Array, Manager N_PROCESSES = 8 def f(results, key): results[key]['d'][3].append(1) def main(): pool = Pool(processes=N_PROCESSES) manager = Manager() results = manager.dict() for key in ['k', 'kk']: results[key] = dict([(key2, [[] for i in range(4)]) for key2 in ['d', 'dd']]) res = [ pool.apply_async(f, key) for key in ['k'] ] map(lambda x: x.wait(), res) print results['k'] print results['k']['d'] print results['k']['d'][3] if __name__ == "__main__": main() --Apple-Mail-15-824396897--