Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sched cancel (wrong item removed from queue) #79124

Closed
ajneu mannequin opened this issue Oct 9, 2018 · 2 comments
Closed

sched cancel (wrong item removed from queue) #79124

ajneu mannequin opened this issue Oct 9, 2018 · 2 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ajneu
Copy link
Mannequin

ajneu mannequin commented Oct 9, 2018

BPO 34943
Superseder
  • bpo-19270: sched.cancel() doesn't distinguish equal events and can break order
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-11-22.10:40:14.610>
    created_at = <Date 2018-10-09.12:28:53.449>
    labels = ['3.7', 'type-bug', 'library']
    title = 'sched cancel (wrong item removed from queue)'
    updated_at = <Date 2021-11-22.10:40:14.610>
    user = 'https://bugs.python.org/ajneu'

    bugs.python.org fields:

    activity = <Date 2021-11-22.10:40:14.610>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-11-22.10:40:14.610>
    closer = 'iritkatriel'
    components = ['Library (Lib)']
    creation = <Date 2018-10-09.12:28:53.449>
    creator = 'ajneu'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34943
    keywords = []
    message_count = 2.0
    messages = ['327396', '327397']
    nosy_count = 1.0
    nosy_names = ['ajneu']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '19270'
    type = 'behavior'
    url = 'https://bugs.python.org/issue34943'
    versions = ['Python 3.6', 'Python 3.7']

    @ajneu
    Copy link
    Mannequin Author

    ajneu mannequin commented Oct 9, 2018

    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?

    @ajneu ajneu mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Oct 9, 2018
    @ajneu
    Copy link
    Mannequin Author

    ajneu mannequin commented Oct 9, 2018

    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant