Skip to content

Use monotonic time for sched, trace and subprocess modules #58895

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
vstinner opened this issue Apr 29, 2012 · 8 comments
Closed

Use monotonic time for sched, trace and subprocess modules #58895

vstinner opened this issue Apr 29, 2012 · 8 comments

Comments

@vstinner
Copy link
Member

BPO 14690
Nosy @rhettinger, @abalkin, @vstinner, @giampaolo
Files
  • use_monotonic.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 2012-05-30.11:31:52.054>
    created_at = <Date 2012-04-29.01:18:53.448>
    labels = []
    title = 'Use monotonic time for sched, trace and subprocess modules'
    updated_at = <Date 2012-05-30.11:31:52.052>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2012-05-30.11:31:52.052>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-05-30.11:31:52.054>
    closer = 'python-dev'
    components = []
    creation = <Date 2012-04-29.01:18:53.448>
    creator = 'vstinner'
    dependencies = []
    files = ['25400']
    hgrepos = []
    issue_num = 14690
    keywords = ['patch']
    message_count = 3.0
    messages = ['159559', '159592', '161945']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'belopolsky', 'vstinner', 'giampaolo.rodola', 'neologix', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue14690'
    versions = []

    @vstinner
    Copy link
    Member Author

    The PEP-418 added a new time.monotonic() function. The sched, trace and subprocess modules should use it, if available, to avoid issues when the system time is changed.

    Attached patch uses the time.monotonic() function when available.

    See also the issue bpo-14222 (same issue for queue and threading) and the PEP-418.

    --

    socket and ssl modules should also use a monotonic clock if available, but these modules are implemented in C. The C implementation of time.monotonic() requires the librt library and is written in the timemodule.c. It requires more work to reuse it in the socket and ssl modules.

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Apr 29, 2012

    LGTM.
    Juste one nitpick: why do you sometimes import the clock source as get_time() and others _time()? _time() looks fine to me.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 30, 2012

    New changeset 1345cf58738d by Victor Stinner in branch 'default':
    Close bpo-14690: Use monotonic clock instead of system clock in the sched,
    http://hg.python.org/cpython/rev/1345cf58738d

    @python-dev python-dev mannequin closed this as completed May 30, 2012
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @serhiy-storchaka
    Copy link
    Member

    It was a broken change for the sched module, because the enterabs() method takes an absolute time.

    @vstinner
    Copy link
    Member Author

    @serhiy-storchaka

    It was a broken change for the sched module, because the enterabs() method takes an absolute time.

    Oh! You commented the change 12 years later. Does your comment mean that something should be changed? That the documentation is incomplete?

    @serhiy-storchaka
    Copy link
    Member

    The documentation definitely should be changed.

    @vstinner
    Copy link
    Member Author

    The documentation definitely should be changed.

    Please open a new issue, or reopen this issue.

    @serhiy-storchaka
    Copy link
    Member

    See #103417.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants