def callLater(self, howlong, *args, **kwargs): rval = posixbase.PosixReactorBase.callLater(self, howlong, *args, **kwargs) if self.timer: timeout = self.timeout() if timeout is None: timeout = howlong sleepUntil = cf.now() + min(timeout, howlong) if sleepUntil < self.timer.getNextFireDate(): self.timer.setNextFireDate(sleepUntil) else: pass return rval
def simulate(self): if self.crashing: return if not self.running: raise ValueError, "You can't simulate a stopped reactor" if self._doRunUntilCurrent: self.runUntilCurrent() if self.crashing: return if self.timer is None: return nap = self.timeout() if nap is None: nap = self.pollInterval else: nap = min(self.pollInterval, nap) if self.running: self.timer.setNextFireDate(cf.now() + nap) if not self._doRunUntilCurrent: self.crash()
def _startup(self): if self.running: raise ValueError, "Can't bootstrap a running reactor" self.timer = cf.PyCFRunLoopTimer(cf.now(), self.pollInterval, self.simulate) self.runLoop.addTimer(self.timer)