]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue 5830: Events are now comparable when the time and type are the same.
authorRaymond Hettinger <python@rcn.com>
Fri, 24 Apr 2009 18:48:59 +0000 (18:48 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 24 Apr 2009 18:48:59 +0000 (18:48 +0000)
Lib/sched.py
Misc/NEWS

index aecdb2a47554aa86599cb353a0aec610a902a2dc..11bb0a3a1861526d5e055e5f565529d86f804efe 100644 (file)
@@ -33,7 +33,13 @@ from collections import namedtuple
 
 __all__ = ["scheduler"]
 
-Event = namedtuple('Event', 'time, priority, action, argument')
+class Event(namedtuple('Event', 'time, priority, action, argument')):
+    def __eq__(s, o): return (s.time, s.priority) == (o.time, o.priority)
+    def __ne__(s, o): return (s.time, s.priority) != (o.time, o.priority)
+    def __lt__(s, o): return (s.time, s.priority) <  (o.time, o.priority)
+    def __le__(s, o): return (s.time, s.priority) <= (o.time, o.priority)
+    def __gt__(s, o): return (s.time, s.priority) >  (o.time, o.priority)
+    def __ge__(s, o): return (s.time, s.priority) >= (o.time, o.priority)
 
 class scheduler:
     def __init__(self, timefunc, delayfunc):
index 99d44cd62bd4c8e549a3db3371e4e783a3e3005c..34d41e6357dc30d24427f1a20b1fbcb18829330a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -35,6 +35,9 @@ Core and Builtins
 Library
 -------
 
+- Issue 5830:  The sched module no longer raises a TypeError when
+  prioritizing Events with the same time and priority.
+
 - Issue #1161031: fix readwrite select flag handling: POLLPRI now
   results in a handle_expt_event call, not handle_read_event, and POLLERR
   and POLLNVAL now call handle_close, not handle_expt_event.  Also,