def __init__(self, *args, **kwargs): self.mutex = threading.RLock() dict.__init__(self, *args, **kwargs) for k in self: if type(self[k]) is dict: self[k] = ThreadsafeDict(self[k])