code: def run(self):
          
          while not self.stopped.isSet():
              try:
                  # if the current state is idle, just block and wait forever
                  # if the current state is any other state, then a timeout of 200ms should
                  # be reasonable in all cases.
                  timeout = (self._state != 'idle') and 0.2 or None
                  rdlist, _, _ = select.select([self._socket.fileno()], [], [], timeout)
                  if not rdlist:
                      if self._state != 'idle':
                          self._state = 'idle'
                      continue
                  data = self._socket.recv(1024)
                  if not data:
                      # check if the socket is still valid
                      try:
                          os.fstat(recv._socket.fileno())
                      except socket.error:
                          break
                      continue
                  code = utils.mangleIR(data, ignore_errors=True)
                  codeName = self.codeMap.get(code)
                  # some manufacturers repeat their IR codes several times in rapid
                  # succession. by tracking the last code, we can eliminate redundant
                  # state changes
                  if codeName and (self._state != codeName):
                      self._state = codeName
                      for callback in self._callbacks:
                          callback(codeName)
              except:
                  time.sleep(0.1)
docs: Main loop of KIRA thread.