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

Don't block on Queue get/put when time is moved back #44783

Closed
xiaowen mannequin opened this issue Mar 29, 2007 · 6 comments
Closed

Don't block on Queue get/put when time is moved back #44783

xiaowen mannequin opened this issue Mar 29, 2007 · 6 comments
Labels
stdlib Python modules in the Lib dir

Comments

@xiaowen
Copy link
Mannequin

xiaowen mannequin commented Mar 29, 2007

BPO 1690578
Nosy @loewis, @rhettinger, @josiahcarlson
Files
  • time.patch
  • 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 2007-04-15.07:28:05.000>
    created_at = <Date 2007-03-29.12:32:29.000>
    labels = ['library']
    title = "Don't block on Queue get/put when time is moved back"
    updated_at = <Date 2007-04-15.07:28:05.000>
    user = 'https://bugs.python.org/xiaowen'

    bugs.python.org fields:

    activity = <Date 2007-04-15.07:28:05.000>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2007-03-29.12:32:29.000>
    creator = 'xiaowen'
    dependencies = []
    files = ['7907']
    hgrepos = []
    issue_num = 1690578
    keywords = ['patch']
    message_count = 6.0
    messages = ['52329', '52330', '52331', '52332', '52333', '52334']
    nosy_count = 4.0
    nosy_names = ['loewis', 'rhettinger', 'josiahcarlson', 'xiaowen']
    pr_nums = []
    priority = 'low'
    resolution = 'rejected'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1690578'
    versions = []

    @xiaowen
    Copy link
    Mannequin Author

    xiaowen mannequin commented Mar 29, 2007

    When Queue get and put methods are called with a timeout, they effectively store the end time and might block until that end time is reached. This breaks if the system time is moved back. The attached patch breaks out of the wait if it detects the time has been moved back.

    @xiaowen xiaowen mannequin closed this as completed Mar 29, 2007
    @xiaowen xiaowen mannequin added the stdlib Python modules in the Lib dir label Mar 29, 2007
    @xiaowen xiaowen mannequin closed this as completed Mar 29, 2007
    @xiaowen xiaowen mannequin added the stdlib Python modules in the Lib dir label Mar 29, 2007
    @josiahcarlson
    Copy link
    Mannequin

    josiahcarlson mannequin commented Apr 9, 2007

    I am unsure if this is a sufficient or correct patch, but the functionality is desirable.

    @rhettinger
    Copy link
    Contributor

    When a system moves time backwards, it breaks a host of invariants, not just the one in the queue module. I would not want some variant of this code used everywhere time differences are computed. Another thought is that the use case is somewhat exceptional and that the solution (readjusting endtime) isn't necessarily the right thing to do.

    @josiahcarlson
    Copy link
    Mannequin

    josiahcarlson mannequin commented Apr 9, 2007

    I agree that it would be better to fix this everywhere we can. But unless we start replacing the generic versions of everything that uses a timeout for platform-specific versions (that have guarantees regarding specified timeouts and notifications), about all we can really do is to patch each item as we go along. I suppose a good first step would be to write a generic "wait for" function that would sit in threading, _Condition.wait() is a good start. From there, one could write platform variants (Windows could use WaitForSingleObject, etc.) that don't change the end time, calling them on a platform if they exist.

    @rhettinger
    Copy link
    Contributor

    I was recommending against "fixing" this everywhere. See related comments on pathc bpo-1607149: Condition.wait timeout fails on clock change.

    Recommend closing this patch. The problem is not the responsibility of every client accessing time() or sleep(). The clients do not have enough information to reliably detect changes and to know how much the time changed. Even if those are known, it is not clear that adjusting the timeout is the always right thing to do.

    Also, this "problem" is somewhat obscure. Lowering the priority to 1 and recommending that the patch (and all like it) be rejected.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Apr 15, 2007

    Rejecting this patch for the same reason bpo-1607149 was rejected.

    @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
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant