def __init__(self, name): self.name = name self._overtime_count = 0 self.sensors = defaultNonedict() self._steps = [] self._err = False self._finished = False self.force(0) self.torque(0) self._fire = "_" self._ping = 0 self._turretangle = 0 self.logfile = None
def loop(r, i): data = i.split('|') sensors = defaultNonedict() for d in data: k, v = d.split(':') if ';' in v: v = v.split(';') vconv = [] for vv in v: try: vvconv = int(vv) except: vvconv = vv vconv.append(vvconv) else: try: vconv = int(v) except: vconv = v sensors[k] = vconv timeout = conf.tick_timeout user_thread = Thread(target=get_response, args=(r, sensors)) response = None user_thread.start() user_thread.join(timeout) if user_thread.isAlive(): global _overtime_count _overtime_count += 1 response = 'TIMEOUT' if _overtime_count > 10: os.kill(os.getpid(), 9) else: _overtime_count = 0 return response or r.response