gdbm objects not iterable?
Steve Holden
steve at holdenweb.com
Wed Oct 3 15:22:13 EDT 2007
Laszlo Nagy wrote:
>
>>> 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?)
>
Why don't you try it and see ... (this is just a sneaky way of saying
"beats me"...(
> I'm just glad that my idea was not rejected instantly. :-)
>
It seems much more sensible than many of the proposals seen on this list.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Sorry, the dog ate my .sigline
More information about the Python-list
mailing list