gdbm objects not iterable?

Laszlo Nagy gandalf at shopzeus.com
Wed Oct 3 21:11:55 CEST 2007


>> E.g. I would not allow to change the keys of the gdbm object during 
>> iteration. I'm not sure how to detect "end of iteration" though.
>>
>> (Maybe I misunderstood your question.)
>>
>>     
> All I meant was that it's essential to trap this condition.
>   
Dictionary size change is easy to detect between two iterations. 
Detecting key changes is more difficult but not hard (with a "last 
modified" timestamp/counter maybe?).

These would not work when there are multiple threads iterating over the 
same gdbm object. I believe I should not do this without locking. (How 
it is implemented in Python with dicts? What happens if I iterate 
through a dict in one thread, and modify it from another thread?)

I'm just glad that my idea was not rejected instantly. :-)

  Laszlo




More information about the Python-list mailing list