[Twisted-Python] delay 0 patch for 1.3 base.py

Here's the patch for callLater with delay of 0, but now for 1.3. (Nice to see the windows installer is now available!) Again, I've tested it, but Twisted regression tests remain to be done. Again, I consign copyrights to Glyph. Again, I'll update http://compstrm.sourceforge.net as soon as I hear word that the regression tests have succeeded. (I STILL have my fingers crossed!) ===== Bill la Forge http://www.geocities.com/laforge49/ ________________________________________________________________________ Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/ --- base.1.3.py 2004-05-21 08:08:58.000000000 +0530 +++ base.py 2004-05-22 10:50:10.015124800 +0530 @@ -368,10 +368,16 @@ assert callable(_f), "%s is not callable" % _f assert sys.maxint >= _seconds >= 0, \ "%s is not greater than or equal to 0 seconds" % (_seconds,) - tple = DelayedCall(seconds() + _seconds, _f, args, kw, - self._pendingTimedCalls.remove, - self._resetCallLater) - insort(self._pendingTimedCalls, tple) + if _seconds != 0: + tple = DelayedCall(_seconds + seconds(), _f, args, kw, + self._pendingTimedCalls.remove, + self._resetCallLater) + insort(self._pendingTimedCalls, tple) + else: + tple = DelayedCall(0, _f, args, kw, + self._pendingTimedCalls.remove, + self._resetCallLater) + self._pendingTimedCalls.append(tple) return tple def _resetCallLater(self, tple): @@ -415,9 +421,13 @@ log.err() count += 1 del self.threadCallQueue[:count] + if not self._pendingTimedCalls: + return now = seconds() + do=[] while self._pendingTimedCalls and (self._pendingTimedCalls[-1].time <= now): - call = self._pendingTimedCalls.pop() + do.append(self._pendingTimedCalls.pop()) + for call in do: try: call.called = 1 call.func(*call.args, **call.kw)
participants (1)
-
Bill la Forge