Skip to content

priority in sched.scheduler is not sufficiently tested #90808

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

Closed
sobolevn opened this issue Feb 5, 2022 · 3 comments
Closed

priority in sched.scheduler is not sufficiently tested #90808

sobolevn opened this issue Feb 5, 2022 · 3 comments
Labels
3.11 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Feb 5, 2022

BPO 46650
Nosy @sobolevn
PRs
  • gh-90808: add more examples to test_sched.test_priority #31144
  • 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 = None
    created_at = <Date 2022-02-05.15:50:10.714>
    labels = ['type-bug', 'tests', '3.11']
    title = '`priority` in `sched.scheduler` is not sufficiently tested'
    updated_at = <Date 2022-02-05.15:51:16.027>
    user = 'https://github.com/sobolevn'

    bugs.python.org fields:

    activity = <Date 2022-02-05.15:51:16.027>
    actor = 'sobolevn'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2022-02-05.15:50:10.714>
    creator = 'sobolevn'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46650
    keywords = ['patch']
    message_count = 1.0
    messages = ['412577']
    nosy_count = 1.0
    nosy_names = ['sobolevn']
    pr_nums = ['31144']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue46650'
    versions = ['Python 3.11']

    @sobolevn
    Copy link
    Member Author

    sobolevn commented Feb 5, 2022

    Right now there only a single test to ensure priority works correctly in scheduler:

    def test_priority(self):
    l = []
    fun = lambda x: l.append(x)
    scheduler = sched.scheduler(time.time, time.sleep)
    for priority in [1, 2, 3, 4, 5]:
    z = scheduler.enterabs(0.01, priority, fun, (priority,))
    scheduler.run()
    self.assertEqual(l, [1, 2, 3, 4, 5])

    It looks like it is not enough. Why?

    for priority in [1, 2, 3, 4, 5]:
      z = scheduler.enterabs(0.01, priority, fun, (priority,))
    scheduler.run()
    self.assertEqual(l, [1, 2, 3, 4, 5])
    

    This test does not actually test different priorities. It only tests that a direct one works correctly. But, this might be a pure coincidence that numbers match. They are spawned in this particular order.

    What if there are equal numbers? Like [1, 2, 1]

    I propose adding more examples to this test. PR is on its way.

    @sobolevn sobolevn added 3.11 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Feb 5, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 21, 2022
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 21, 2022
    miss-islington added a commit that referenced this issue Sep 21, 2022
    (cherry picked from commit 57463d4)
    
    Co-authored-by: Nikita Sobolev <[email protected]>
    miss-islington added a commit that referenced this issue Sep 21, 2022
    (cherry picked from commit 57463d4)
    
    Co-authored-by: Nikita Sobolev <[email protected]>
    @larryhastings
    Copy link
    Contributor

    Can this be closed?

    @JelleZijlstra
    Copy link
    Member

    yes

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants