From 7c3dea75d4ad19acccc9833cddb2be0b199007d7 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 1 May 2011 14:33:28 -0700 Subject: [PATCH] Fix for python2.5: heapq used to use __le__ instead of __lt__ --- tornado/ioloop.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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. -- 2.47.3