Skip to content

Commit c6d191d

Browse files
[3.13] Fix various issues in the 'Timer File Descriptors' documentation (GH-156027) (#156480)
(cherry picked from commit 13ab4c2) Co-authored-by: Omar Sandoval <osandov@osandov.com>
1 parent 6df11f0 commit c6d191d

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

Doc/library/os.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4066,16 +4066,17 @@ Naturally, they are all only available on Linux.
40664066
- :const:`time.CLOCK_BOOTTIME` (Since Linux 3.15 for timerfd_create)
40674067

40684068
If *clockid* is :const:`time.CLOCK_REALTIME`, a settable system-wide
4069-
real-time clock is used. If system clock is changed, timer setting need
4070-
to be updated. To cancel timer when system clock is changed, see
4069+
real-time clock is used. If the system clock is changed, the timer setting
4070+
needs to be updated. To cancel the timer when the system clock is changed, see
40714071
:const:`TFD_TIMER_CANCEL_ON_SET`.
40724072

40734073
If *clockid* is :const:`time.CLOCK_MONOTONIC`, a non-settable monotonically
40744074
increasing clock is used. Even if the system clock is changed, the timer
40754075
setting will not be affected.
40764076

4077-
If *clockid* is :const:`time.CLOCK_BOOTTIME`, same as :const:`time.CLOCK_MONOTONIC`
4078-
except it includes any time that the system is suspended.
4077+
If *clockid* is :const:`time.CLOCK_BOOTTIME`, it is the same as
4078+
:const:`time.CLOCK_MONOTONIC` except it includes any time that the system
4079+
is suspended.
40794080

40804081
The file descriptor's behaviour can be modified by specifying a *flags* value.
40814082
Any of the following variables may be used, combined using bitwise OR
@@ -4086,8 +4087,8 @@ Naturally, they are all only available on Linux.
40864087

40874088
If :const:`TFD_NONBLOCK` is not set as a flag, :func:`read` blocks until
40884089
the timer expires. If it is set as a flag, :func:`read` doesn't block, but
4089-
If there hasn't been an expiration since the last call to read,
4090-
:func:`read` raises :class:`OSError` with ``errno`` is set to
4090+
if there hasn't been an expiration since the last call to read,
4091+
:func:`read` raises :class:`OSError` with ``errno`` set to
40914092
:const:`errno.EAGAIN`.
40924093

40934094
:const:`TFD_CLOEXEC` is always set by Python automatically.
@@ -4102,7 +4103,7 @@ Naturally, they are all only available on Linux.
41024103
.. versionadded:: 3.13
41034104

41044105

4105-
.. function:: timerfd_settime(fd, /, *, flags=flags, initial=0.0, interval=0.0)
4106+
.. function:: timerfd_settime(fd, /, *, flags=0, initial=0.0, interval=0.0)
41064107

41074108
Alter a timer file descriptor's internal timer.
41084109
This function operates the same interval timer as :func:`timerfd_settime_ns`.
@@ -4117,12 +4118,11 @@ Naturally, they are all only available on Linux.
41174118
- :const:`TFD_TIMER_CANCEL_ON_SET`
41184119

41194120
The timer is disabled by setting *initial* to zero (``0``).
4120-
If *initial* is equal to or greater than zero, the timer is enabled.
4121+
If *initial* is greater than zero, the timer is enabled.
41214122
If *initial* is less than zero, it raises an :class:`OSError` exception
4122-
with ``errno`` set to :const:`errno.EINVAL`
4123+
with ``errno`` set to :const:`errno.EINVAL`.
41234124

41244125
By default the timer will fire when *initial* seconds have elapsed.
4125-
(If *initial* is zero, timer will fire immediately.)
41264126

41274127
However, if the :const:`TFD_TIMER_ABSTIME` flag is set,
41284128
the timer will fire when the timer's clock
@@ -4133,13 +4133,13 @@ Naturally, they are all only available on Linux.
41334133
If *interval* is greater than zero, the timer fires every time *interval*
41344134
seconds have elapsed since the previous expiration.
41354135
If *interval* is less than zero, it raises :class:`OSError` with ``errno``
4136-
set to :const:`errno.EINVAL`
4136+
set to :const:`errno.EINVAL`.
41374137

41384138
If the :const:`TFD_TIMER_CANCEL_ON_SET` flag is set along with
41394139
:const:`TFD_TIMER_ABSTIME` and the clock for this timer is
41404140
:const:`time.CLOCK_REALTIME`, the timer is marked as cancelable if the
41414141
real-time clock is changed discontinuously. Reading the descriptor is
4142-
aborted with the error ECANCELED.
4142+
aborted with the error :const:`errno.ECANCELED`.
41434143

41444144
Linux manages system clock as UTC. A daylight-savings time transition is
41454145
done by changing time offset only and doesn't cause discontinuous system

Modules/clinic/posixmodule.c.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10890,17 +10890,17 @@ os.timerfd_settime_ns
1089010890
flags: int = 0
1089110891
0 or a bit mask of TFD_TIMER_ABSTIME or TFD_TIMER_CANCEL_ON_SET.
1089210892
initial: long_long = 0
10893-
initial expiration timing in seconds.
10893+
initial expiration timing in nanoseconds.
1089410894
interval: long_long = 0
10895-
interval for the timer in seconds.
10895+
interval for the timer in nanoseconds.
1089610896
1089710897
Alter a timer file descriptor's internal timer in nanoseconds.
1089810898
[clinic start generated code]*/
1089910899

1090010900
static PyObject *
1090110901
os_timerfd_settime_ns_impl(PyObject *module, int fd, int flags,
1090210902
long long initial, long long interval)
10903-
/*[clinic end generated code: output=6273ec7d7b4cc0b3 input=261e105d6e42f5bc]*/
10903+
/*[clinic end generated code: output=6273ec7d7b4cc0b3 input=94bdcea7292157eb]*/
1090410904
{
1090510905
struct itimerspec new_value;
1090610906
struct itimerspec old_value;
@@ -10929,12 +10929,12 @@ os.timerfd_gettime
1092910929
A timer file descriptor.
1093010930
/
1093110931
10932-
Return a tuple of a timer file descriptor's (interval, next expiration) in float seconds.
10932+
Return a tuple of a timer file descriptor's (next expiration, interval) in float seconds.
1093310933
[clinic start generated code]*/
1093410934

1093510935
static PyObject *
1093610936
os_timerfd_gettime_impl(PyObject *module, int fd)
10937-
/*[clinic end generated code: output=ec5a94a66cfe6ab4 input=8148e3430870da1c]*/
10937+
/*[clinic end generated code: output=ec5a94a66cfe6ab4 input=6511475a40bc5ee6]*/
1093810938
{
1093910939
struct itimerspec curr_value;
1094010940
int result;
@@ -10955,12 +10955,12 @@ os.timerfd_gettime_ns
1095510955
A timer file descriptor.
1095610956
/
1095710957
10958-
Return a tuple of a timer file descriptor's (interval, next expiration) in nanoseconds.
10958+
Return a tuple of a timer file descriptor's (next expiration, interval) in nanoseconds.
1095910959
[clinic start generated code]*/
1096010960

1096110961
static PyObject *
1096210962
os_timerfd_gettime_ns_impl(PyObject *module, int fd)
10963-
/*[clinic end generated code: output=580633a4465f39fe input=a825443e4c6b40ac]*/
10963+
/*[clinic end generated code: output=580633a4465f39fe input=8322cb9855b40a9e]*/
1096410964
{
1096510965
struct itimerspec curr_value;
1096610966
int result;

0 commit comments

Comments
 (0)