def __getitem__(self, attr): self.lock() try: val = dict.__getitem__(self, attr) finally: self.unlock() return val