From: Ben Darnell Date: Sun, 1 May 2011 21:33:28 +0000 (-0700) Subject: Fix for python2.5: heapq used to use __le__ instead of __lt__ X-Git-Tag: v2.0.0~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c3dea75d4ad19acccc9833cddb2be0b199007d7;p=thirdparty%2Ftornado.git Fix for python2.5: heapq used to use __le__ instead of __lt__ --- diff --git a/tornado/ioloop.py b/tornado/ioloop.py index b7101672f..a7bdffc3c 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -397,10 +397,18 @@ class _Timeout(object): self.deadline = deadline self.callback = callback + # Comparison methods to sort by deadline, with object id as a tiebreaker + # to guarantee a consistent ordering. The heapq module uses __le__ + # in python2.5, and __lt__ in 2.6+ (sort() and most other comparisons + # use __lt__). def __lt__(self, other): return ((self.deadline, id(self)) < (other.deadline, id(other))) + def __le__(self, other): + return ((self.deadline, id(self)) <= + (other.deadline, id(other))) + class PeriodicCallback(object): """Schedules the given callback to be called periodically.