labrad / servers

LabRAD servers
24 stars 21 forks source link

Remote registry leads to unpredictable errors #331

Closed christopherquintana closed 8 years ago

christopherquintana commented 8 years ago

This happens when I run scans that try to write to the registry. For example, when I run calculateReadoutCenters in /pyle/dataking/singleQubit, I sometimes get a KeyError and sometimes get a RuntimeError (both are shown below).

According to Matthew, this has to do with thread safety in the registry wrapper and the new remote registry delivering notifications in different orders each time.

Stack trace of KeyError:

KeyError                                  Traceback (most recent call last)
<ipython-input-5-672f830ed540> in <module>()
----> 1 sq.calculateReadoutCenters(s, 'q2', plot=False)

/usr/local/google/home/bryanchen/src/pyle/pyle/dataking/singleQubit.pyc in calculateReadoutCenters(Sample, measure, stats, states, collect, update, plot, noisy)
    321         Qubit['readoutProbabilities'] = prob_matrix
    322         Qubit['readoutMqCal'] = [measure]
--> 323         Qubit['fid0'] = fids[0]
    324         Qubit['fid1'] = fids[1]
    325 

/usr/local/google/home/bryanchen/src/pyle/pyle/util/registry.pyc in __setitem__(self, name, value)
    227         if self.__contains__(name):
    228             msg = "__setitem__ {} to {} from {} in path {}".format(name, value,
--> 229                                                                    self[name],
    230                                                                    self._dir)
    231             log.info(msg)

/usr/local/google/home/bryanchen/src/pyle/pyle/util/registry.pyc in __getitem__(self, name)
    209         '''
    210         self._validate()
--> 211         self.update_keys()
    212         if name == '..' and len(self._dir) > 1:
    213             return RegistryWrapper(self._cxn, path=self._dir[:-1])

/usr/local/google/home/bryanchen/src/pyle/pyle/util/registry.pyc in update_keys(self)
    148         result = p.send()
    149         for k in self._updated_keys:
--> 150             self._keys[k] = result[k]
    151         self._updated_keys.clear()
    152 

/usr/local/google/home/bryanchen/src/pylabrad/labrad/support.pyc in __getitem__(self, key)
    184 
    185     def __getitem__(self, key):
--> 186         return self.settings[key]

/usr/local/google/home/bryanchen/src/pylabrad/labrad/support.pyc in __getitem__(self, k)
    128         if k in self.aliases:
    129             k = self.aliases[k]
--> 130         return dict.__getitem__(self, k)
    131 
    132     def _updateAliases(self, k, *aliases):

KeyError: 'readoutMqCal'

Stack trace of RuntimeError:

RuntimeError                              Traceback (most recent call last)
<ipython-input-23-16187de78e09> in <module>()
----> 1 sq.calculateReadoutCenters(s, 'q2', plot=True)

/usr/local/google/home/bryanchen/src/pyle/pyle/dataking/singleQubit.pyc in calculateReadoutCenters(Sample, measure, stats, states, collect, update, plot, noisy)
    320         Qubit['readoutFidelities'] = fids
    321         Qubit['readoutProbabilities'] = prob_matrix
--> 322         Qubit['readoutMqCal'] = [measure]
    323         Qubit['fid0'] = fids[0]
    324         Qubit['fid1'] = fids[1]

/usr/local/google/home/bryanchen/src/pyle/pyle/util/registry.pyc in __setitem__(self, name, value)
    227         if self.__contains__(name):
    228             msg = "__setitem__ {} to {} from {} in path {}".format(name, value,
--> 229                                                                    self[name],
    230                                                                    self._dir)
    231             log.info(msg)

/usr/local/google/home/bryanchen/src/pyle/pyle/util/registry.pyc in __getitem__(self, name)
    209         '''
    210         self._validate()
--> 211         self.update_keys()
    212         if name == '..' and len(self._dir) > 1:
    213             return RegistryWrapper(self._cxn, path=self._dir[:-1])

/usr/local/google/home/bryanchen/src/pyle/pyle/util/registry.pyc in update_keys(self)
    144             return
    145         p = self._packet()
--> 146         for k in self._updated_keys:
    147             p.get(k, key=k)
    148         result = p.send()

RuntimeError: Set changed size during iteration
maffoo commented 8 years ago

Closing this since the problem is in pyle.