--- base.py.old 2009-06-25 01:33:56.000000000 +0300 +++ base.py 2009-06-25 01:45:52.000000000 +0300 @@ -23,6 +23,10 @@ fcntl = None import traceback +def validfloat(x,msg=None): + return repr(x)!='nan' + + from twisted.internet.interfaces import IReactorCore, IReactorTime, IReactorThreads from twisted.internet.interfaces import IResolverSimple, IReactorPluggableResolver from twisted.internet.interfaces import IConnector, IDelayedCall @@ -63,6 +67,7 @@ used to determine the current time any time that information is needed. """ + assert validfloat(time) self.time, self.func, self.args, self.kw = time, func, args, kw self.resetter = reset self.canceller = cancel @@ -79,6 +84,8 @@ @return: The number of seconds after the epoch at which this call is scheduled to be made. """ + assert validfloat(self.time) + assert validfloat(self.delayed_time) return self.time + self.delayed_time def cancel(self): @@ -115,13 +122,16 @@ elif self.called: raise error.AlreadyCalled else: + assert validfloat(secondsFromNow) newTime = self.seconds() + secondsFromNow if newTime < self.time: self.delayed_time = 0 self.time = newTime + assert validfloat(self.time) self.resetter(self) else: self.delayed_time = newTime - self.time + assert validfloat(self.delayed_time) def delay(self, secondsLater): """Reschedule this call for a later time @@ -138,13 +148,16 @@ elif self.called: raise error.AlreadyCalled else: + assert validfloat(secondsLater) self.delayed_time += secondsLater if self.delayed_time < 0: self.activate_delay() self.resetter(self) + assert validfloat(self.time) def activate_delay(self): self.time += self.delayed_time + assert validfloat(self.time) self.delayed_time = 0 def active(self): @@ -651,6 +664,10 @@ assert callable(_f), "%s is not callable" % _f assert sys.maxint >= _seconds >= 0, \ "%s is not greater than or equal to 0 seconds" % (_seconds,) + + assert validfloat(_seconds) + assert repr(self.seconds())!='nan', 'self.seconds() [really: %r] returned NaN! %r,%r,%r'%(self.seconds,self.seconds(),self.seconds(),self.seconds()) + tple = DelayedCall(self.seconds() + _seconds, _f, args, kw, self._cancelCallLater, self._moveCallLaterSooner, @@ -741,6 +758,11 @@ self._insertNewDelayedCalls() now = self.seconds() + + if self._pendingTimedCalls and repr(self._pendingTimedCalls[0].time)=='nan': + print 'NAN TIME DETECTED', repr(self._pendingTimedCalls[0].time), self._pendingTimedCalls[0].__dict__ + self._pendingTimedCalls[0].time=0 + while self._pendingTimedCalls and (self._pendingTimedCalls[0].time <= now): call = heappop(self._pendingTimedCalls) if call.cancelled: