[issue19270] sched.cancel() breaks events order

Raymond Hettinger report at bugs.python.org
Mon Oct 21 07:12:14 CEST 2013


Raymond Hettinger added the comment:

> 1. sched.cancel() can remove wrong event
> (because it uses equality instead identity).

I don't think this is a bug.  The user should be able to define events that can be compared on equality.  It is the user's responsibility to make sure that events are distinct (this is no different than how list.remove() works for example).

> 2. sched.cancel() change order of equal (by time and priority) events.

That is allowed.   We make no stability guarantees.  Plus it just makes sense that events with the same time and priority are non-deterministic.

Note, to add stability we would have to store the order that events were added.  This would slow down the code.

Add note that Tornado uses heapq in its ioloop in the same way that the schedule module does.  It too makes no effort to preserve input order.

I recommend closing this as "not a bug" or as an "further document the existing behaviors".

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19270>
_______________________________________


More information about the Python-bugs-list mailing list