On May 10, 3:57 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > IMHO you are probably best to write a thread-safe class which uses an > ordinary dict (and has a nicely limited interface) rather than trying to > produce a completely thread-safe dict type.
thanks, sounds good! but that again: from __future__ import with_statement class safe_dict(dict): def __init__(self): self.lock = threading.Lock() self.d = {} def __getitem__(self, key): with self.lock: return self.d[key] def __setitem__(self, key, value): with self.lock: self.d[key] = value def __delitem__(self, key): with self.lock: del self.d[key] - in __getitem__, does it release the lock after returning the item? - wouldn't it be better to use threading.RLock, mutex, ... instead? -- http://mail.python.org/mailman/listinfo/python-list