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.scheduler docs improvement #103417

Closed
nburns opened this issue Apr 10, 2023 · 2 comments
Closed

sched.scheduler docs improvement #103417

nburns opened this issue Apr 10, 2023 · 2 comments
Labels
docs Documentation in the Doc dir

Comments

@nburns
Copy link
Contributor

nburns commented Apr 10, 2023

Documentation

The docs for sched.scheduler have an example that uses time.time as the timefunc https://docs.python.org/3/library/sched.html#sched.scheduler

Using time.time instead of time.monotonic (the default value of sched.scheduler) creates the potential for "strange things" to happen when seasonal time shifts make the system clock go backwards, resulting in bugs in user's code.

It seems like it would be better to use time.monononic so as to introduce better practices to people learning the language.

Linked PRs

@nburns nburns added the docs Documentation in the Doc dir label Apr 10, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 12, 2023
pythonGH-103418)

(cherry picked from commit f2b7ecb)

Co-authored-by: Nick Burns <nburns@users.noreply.github.com>
miss-islington added a commit that referenced this issue Apr 12, 2023
…103418)

(cherry picked from commit f2b7ecb)

Co-authored-by: Nick Burns <nburns@users.noreply.github.com>
@hauntsaninja
Copy link
Contributor

Thank you!

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jan 28, 2024

It broke the example which expects that the result of timefunc() is larger than 1_650_000_000 (~ 2022-Apr-15). It is not so for time.monotonic(), unless your system has more than 50 years uptime. See #111497.

@serhiy-storchaka serhiy-storchaka changed the title sched.scheduler docs improvment sched.scheduler docs improvement Jan 31, 2024
serhiy-storchaka pushed a commit that referenced this issue Feb 25, 2024
Arguments to enterabs() are specified as Unix time.
If the scheduler use the time.monotonic timer, the code will take
decades to complete.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 25, 2024
Arguments to enterabs() are specified as Unix time.
If the scheduler use the time.monotonic timer, the code will take
decades to complete.
(cherry picked from commit cb287d3)

Co-authored-by: mauricelambert <50479118+mauricelambert@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 25, 2024
Arguments to enterabs() are specified as Unix time.
If the scheduler use the time.monotonic timer, the code will take
decades to complete.
(cherry picked from commit cb287d3)

Co-authored-by: mauricelambert <50479118+mauricelambert@users.noreply.github.com>
serhiy-storchaka pushed a commit that referenced this issue Feb 25, 2024
Arguments to enterabs() are specified as Unix time.
If the scheduler use the time.monotonic timer, the code will take
decades to complete.
(cherry picked from commit cb287d3)

Co-authored-by: mauricelambert <50479118+mauricelambert@users.noreply.github.com>
serhiy-storchaka pushed a commit that referenced this issue Feb 25, 2024
Arguments to enterabs() are specified as Unix time.
If the scheduler use the time.monotonic timer, the code will take
decades to complete.
(cherry picked from commit cb287d3)

Co-authored-by: mauricelambert <50479118+mauricelambert@users.noreply.github.com>
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this issue Mar 4, 2024
Arguments to enterabs() are specified as Unix time.
If the scheduler use the time.monotonic timer, the code will take
decades to complete.
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
Arguments to enterabs() are specified as Unix time.
If the scheduler use the time.monotonic timer, the code will take
decades to complete.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

3 participants