def tmp_deleted_purge(self, timeout=32): """After a `timeout' seconds, restore a node added in the tmp_deleted cache""" new_tmp_deleted = {} curt = time() for lvl, id in self.tmp_deleted: t = self.tmp_deleted[lvl, id] if curt-t >= timeout: self.node_add(lvl, id, silent=1) else: new_tmp_deleted[lvl, id] = t self.tmp_deleted = new_tmp_deleted
def tmp_deleted_add(self, lvl, id): self.tmp_deleted[lvl, id] = time() self.node_del(lvl, id, silent=1)