diff --git a/hazelcast/reactor.py b/hazelcast/reactor.py index 0ba4c7426c..3e6e14ee95 100644 --- a/hazelcast/reactor.py +++ b/hazelcast/reactor.py @@ -6,8 +6,10 @@ import sys import threading import time -from hazelcast.six.moves import queue from collections import deque +from functools import total_ordering + +from hazelcast.six.moves import queue from hazelcast.connection import Connection, BUFFER_SIZE from hazelcast.exception import HazelcastError @@ -191,6 +193,7 @@ def close(self, cause): self._connection_closed_callback(self, cause) +@total_ordering class Timer(object): canceled = False @@ -199,6 +202,15 @@ def __init__(self, end, timer_ended_cb, timer_canceled_cb): self.timer_ended_cb = timer_ended_cb self.timer_canceled_cb = timer_canceled_cb + def __eq__(self, other): + return self.end == other.end + + def __ne__(self, other): + return not (self == other) + + def __lt__(self, other): + return self.end < other.end + def cancel(self): self.canceled = True self.timer_canceled_cb(self)