[issue19270] sched.cancel() breaks events order

2013-10-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: This module has been around for a long time and no users have reported any issues with respect to event ordering. The logic is essentially the same as is used in popular event loops like Tornado. Please don't just make-up a new invariant for this module.

[issue19270] sched.cancel() breaks events order

2013-10-21 Thread STINNER Victor
STINNER Victor added the comment: Victor: "On Windows, the precision of time.monotonic() is worse (around 16 ms), so two events at the same time is more likely." Antoine: "This seems quite irrelevant:" I would be interested of the same test on Windows. --

[issue19270] sched.cancel() breaks events order

2013-10-21 Thread STINNER Victor
STINNER Victor added the comment: > ... for two calls to time.time() to give the exact same outcome sched now uses time.monotonic() since Python 3.3. In Python 2.7, there is no default timer, but I get that users pick time.time(). (Oh, sched has no unit test in Python 2.7.) -- __

[issue19270] sched.cancel() breaks events order

2013-10-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: > > ... for two calls to time.time() to give the exact same outcome > > sched now uses time.monotonic() since Python 3.3. This seems quite irrelevant: >>> len(set(time.monotonic() for i in range(100))) 100 -- _

[issue19270] sched.cancel() breaks events order

2013-10-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Does it occur frequently to schedule two events at exactly the same > time? On Linux, clocks have a good precision, even time.monotonic(). It depends how you calculate your timestamps, I'd say :-) It's unlikely for two calls to time.time() to give the exact sa

[issue19270] sched.cancel() breaks events order

2013-10-21 Thread STINNER Victor
STINNER Victor added the comment: > That is allowed. We make no stability guarantees. Plus it just makes sense > that events with the same time and priority are non-deterministic. It would be nice to keep the insertion order. If it is not guaranteed, it must be well documented (big red warn

[issue19270] sched.cancel() breaks events order

2013-10-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If the order of events with the same time and priority doesn't matter, we can optimize the queue property more than 10 times by using sort() (see cancel_4.patch in issue13451). -- ___ Python tracker

[issue19270] sched.cancel() breaks events order

2013-10-20 Thread Raymond Hettinger
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

[issue19270] sched.cancel() breaks events order

2013-10-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Actually there are two bugs: 1. sched.cancel() can remove wrong event (because it uses equality instead identity). 2. sched.cancel() change order of equal (by time and priority) events. -- ___ Python tracker

[issue19270] sched.cancel() breaks events order

2013-10-16 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: sched.cancel() breaks events order if events are scheduled on same time and have same priority. Patch contains tests which expose this issue. -- components: Library (Lib) files: sched_test_stable.patch keywords: patch messages: 200040 nosy: giampao