def _read_config_callback(self, data):
        """Callback function when the ZKConfigManager reads new config data.

        Args:
            data: A string, the new data in the config file.

        """
        # In case of corrupted data.
        try:
            decoded_data = json.loads(data)
            if type(decoded_data) is dict:
                valid_data = {}
                # After dumping a dict to json and then loading it back,
                # all keys in the original dict will be converted to str
                # type, regardless what original types they have. We shall
                # convert keys back to certain type if it is specified.
                try:
                    for k, v in decoded_data.items():
                        if self.key_type is not None:
                            k = self.key_type(k)
                        valid_data[k] = v
                except __HOLE__:
                    log.error("Loaded dict contains key(s) that are not able to be converted to the original type.")
                    valid_data = {}
                self._dict = valid_data
            else:
                log.error("Loaded data: bad format, expecting a dict")
                self._dict = {}
        except Exception:
            log.error("Unable to load data, exception encountered")
            self._dict = {}
dataset/ETHPy150Open pinterest/kingpin/kingpin/manageddata/managed_datastructures.py/ManagedHashMap._read_config_callback