class Supervisor: def __init__(self): self.restarts = 0 if sys.implementation.name != "circuitpython": while True: (PARENT, CHILD) = Pipe() self.child=CHILD FORK = os.fork() if FORK == 0: break; missed = 0 n = 0 while missed < 6: if time.time() > n: print("restart count", self.restarts) n = time.time() + 60 if PARENT.poll(10): missed = 0 PARENT.recv() else: print("missed checkin", missed) missed = missed + 1 print("ashes to ashes") subprocess.run(["kill", "-9", str(FORK)], check=True) self.restarts = self.restarts + 1 def ping(self): if sys.implementation.name != "circuitpython": self.child.send("sup") def step(self): self.ping()
Generated At 2023-03-29T12:13:38-0700 original