> - in __getitem__, does it release the lock after returning the item?

Yes, it does.

> - wouldn't it be better to use threading.RLock, mutex, ... instead?

Better in what sense? Performance-wise? Semantically? Performance-wise,
the best thing would be to do

safe_dict = dict

because the builtin dict is already thread-safe unless user-defined
__hash__ or __eq__ methods get invoked (in which case the dictionary
still works correctly - it's only that it may get modified while
__hash__ or __eq__ is running).

Semantically, it would be better to use a threading.RLock, if you
expect that __hash__ or __eq__ may access the dictionary recursively.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to