This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sched cancel (wrong item removed from queue)
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: sched.cancel() doesn't distinguish equal events and can break order
View: 19270
Assigned To: Nosy List: ajneu
Priority: normal Keywords:

Created on 2018-10-09 12:28 by ajneu, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg327396 - (view) Author: ajneu (ajneu) Date: 2018-10-09 12:28
Hi, 

in the code given below, the last assert fails
when running with 
/mingw64/bin/python3 (Python 3.7.0 -- mingw64's python3 from msys2 project)
C:\Python36\python.exe (Python 3.6.6 -- windows installer)

It does not fail when running with
/usr/bin/python3 (Python 3.6.6 -- msys's python3 from msys2 project)






import sched, time, threading

class A(threading.Thread):
    def __init__(self, sched):
        threading.Thread.__init__(self)
        self._sched = sched
        self.start()

    def run(self):
        self._sched.run()




s = sched.scheduler(time.monotonic, time.sleep)

ev1=None
def go1(a=''):
    print(a)
    global ev1
    ev1 = s.enterabs(time.monotonic()+1, 1, go1, argument=('a',))

ev2=None 
def go2(a=''):
    print(a)
    global ev2
    ev2 = s.enterabs(time.monotonic()+1, 1, go2, argument=('b',))


ev1 = s.enterabs(time.monotonic()+1, 1, go1, argument=('a',))
ev2 = s.enterabs(time.monotonic()+1, 1, go2, argument=('b',))
a = A(s)
time.sleep(2.5)
print('schedu queue before', s.queue)
assert 1 == 1
print('remove', ev2)
assert ev2 in s.queue
s.cancel(ev2)
print('schedu queue after', s.queue)
assert ev2 not in s.queue   # fails (SOMETIMES)


# what is going on here???
# does the last assert also fail from anybody else?
msg327397 - (view) Author: ajneu (ajneu) Date: 2018-10-09 12:46
Ah ...
https://bugs.python.org/issue19270 amazing!

assert ev1 == ev2 
does not fail! (the equality just checks timestamp as far as I can see)

Terrible. In particular: Terrible if the documentation blatently lies to me: https://docs.python.org/3/library/sched.html#sched.scheduler.cancel
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 79124
2021-11-22 10:40:14iritkatrielsetstatus: open -> closed
superseder: sched.cancel() doesn't distinguish equal events and can break order
resolution: duplicate
stage: resolved
2018-10-09 12:46:29ajneusetmessages: + msg327397
2018-10-09 12:28:53ajneucreate