This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Can't iterate over multiprocessing.managers.DictProxy
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: jnoller Nosy List: asksol, jjconti, jnoller
Priority: normal Keywords:

Created on 2010-09-01 13:51 by jjconti, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg115302 - (view) Author: Juan José Conti (jjconti) * Date: 2010-09-01 13:51
I expected I could iterate over a DictProxy as I do over a regular dict.

>>> from multiprocessing import Manager
>>> m = Manager()
>>> d = m.dict()
>>> d
<DictProxy object, typeid 'dict' at 0x98a240c>
>>> for x in d:
...     print x
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 2, in __getitem__
  File "/usr/lib/python2.6/multiprocessing/managers.py", line 740, in _callmethod
    raise convert_to_error(kind, result)
KeyError: 0
>>> d['a'] = 1
>>> for x in d:
...     print x
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 2, in __getitem__
  File "/usr/lib/python2.6/multiprocessing/managers.py", line 740, in _callmethod
    raise convert_to_error(kind, result)
KeyError: 0
msg115932 - (view) Author: Ask Solem (asksol) (Python committer) Date: 2010-09-09 08:24
> I expected I could iterate over a DictProxy as I do over a
> regular dict.

DictProxy doesn't support iterkeys(), itervalues(), or iteritems() either.
So while

    iter(d)

could do
     iter(d.keys())

behind the scenes, it would mask the fact that this would not return
an *iterator* over the keys, but send a potentially long list of keys back to the client.
History
Date User Action Args
2022-04-11 14:57:06adminsetgithub: 53942
2010-11-02 14:41:52asksolsetstatus: open -> closed
resolution: not a bug
2010-09-09 08:24:46asksolsetmessages: + msg115932
2010-09-06 03:10:48r.david.murraysetnosy: + asksol
2010-09-01 19:02:09pitrousetversions: + Python 3.1, Python 3.2, - Python 2.6
nosy: + jnoller

assignee: jnoller
type: behavior
stage: needs patch
2010-09-01 13:51:14jjconticreate