Skip to content

Commit 3d65862

Browse files
[3.15] Fix various issues in the 'Timer File Descriptors' documentation (GH-156027)
(cherry picked from commit 13ab4c2) Co-authored-by: Omar Sandoval <osandov@osandov.com> Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent 431f526 commit 3d65862

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
@@ -4553,16 +4553,17 @@ Naturally, they are all only available on Linux.
45534553
- :const:`time.CLOCK_BOOTTIME` (Since Linux 3.15 for timerfd_create)
45544554

45554555
If *clockid* is :const:`time.CLOCK_REALTIME`, a settable system-wide
4556-
real-time clock is used. If system clock is changed, timer setting need
4557-
to be updated. To cancel timer when system clock is changed, see
4556+
real-time clock is used. If the system clock is changed, the timer setting
4557+
needs to be updated. To cancel the timer when the system clock is changed, see
45584558
:const:`TFD_TIMER_CANCEL_ON_SET`.
45594559

45604560
If *clockid* is :const:`time.CLOCK_MONOTONIC`, a non-settable monotonically
45614561
increasing clock is used. Even if the system clock is changed, the timer
45624562
setting will not be affected.
45634563

4564-
If *clockid* is :const:`time.CLOCK_BOOTTIME`, same as :const:`time.CLOCK_MONOTONIC`
4565-
except it includes any time that the system is suspended.
4564+
If *clockid* is :const:`time.CLOCK_BOOTTIME`, it is the same as
4565+
:const:`time.CLOCK_MONOTONIC` except it includes any time that the system
4566+
is suspended.
45664567

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

45744575
If :const:`TFD_NONBLOCK` is not set as a flag, :func:`read` blocks until
45754576
the timer expires. If it is set as a flag, :func:`read` doesn't block, but
4576-
If there hasn't been an expiration since the last call to read,
4577-
:func:`read` raises :class:`OSError` with ``errno`` is set to
4577+
if there hasn't been an expiration since the last call to read,
4578+
:func:`read` raises :class:`OSError` with ``errno`` set to
45784579
:const:`errno.EAGAIN`.
45794580

45804581
:const:`TFD_CLOEXEC` is always set by Python automatically.
@@ -4589,7 +4590,7 @@ Naturally, they are all only available on Linux.
45894590
.. versionadded:: 3.13
45904591

45914592

4592-
.. function:: timerfd_settime(fd, /, *, flags=flags, initial=0.0, interval=0.0)
4593+
.. function:: timerfd_settime(fd, /, *, flags=0, initial=0.0, interval=0.0)
45934594

45944595
Alter a timer file descriptor's internal timer.
45954596
This function operates the same interval timer as :func:`timerfd_settime_ns`.
@@ -4604,12 +4605,11 @@ Naturally, they are all only available on Linux.
46044605
- :const:`TFD_TIMER_CANCEL_ON_SET`
46054606

46064607
The timer is disabled by setting *initial* to zero (``0``).
4607-
If *initial* is equal to or greater than zero, the timer is enabled.
4608+
If *initial* is greater than zero, the timer is enabled.
46084609
If *initial* is less than zero, it raises an :class:`OSError` exception
4609-
with ``errno`` set to :const:`errno.EINVAL`
4610+
with ``errno`` set to :const:`errno.EINVAL`.
46104611

46114612
By default the timer will fire when *initial* seconds have elapsed.
4612-
(If *initial* is zero, timer will fire immediately.)
46134613

46144614
However, if the :const:`TFD_TIMER_ABSTIME` flag is set,
46154615
the timer will fire when the timer's clock
@@ -4620,13 +4620,13 @@ Naturally, they are all only available on Linux.
46204620
If *interval* is greater than zero, the timer fires every time *interval*
46214621
seconds have elapsed since the previous expiration.
46224622
If *interval* is less than zero, it raises :class:`OSError` with ``errno``
4623-
set to :const:`errno.EINVAL`
4623+
set to :const:`errno.EINVAL`.
46244624

46254625
If the :const:`TFD_TIMER_CANCEL_ON_SET` flag is set along with
46264626
:const:`TFD_TIMER_ABSTIME` and the clock for this timer is
46274627
:const:`time.CLOCK_REALTIME`, the timer is marked as cancelable if the
46284628
real-time clock is changed discontinuously. Reading the descriptor is
4629-
aborted with the error ECANCELED.
4629+
aborted with the error :const:`errno.ECANCELED`.
46304630

46314631
Linux manages system clock as UTC. A daylight-savings time transition is
46324632
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
@@ -11471,17 +11471,17 @@ os.timerfd_settime_ns
1147111471
flags: int = 0
1147211472
0 or a bit mask of TFD_TIMER_ABSTIME or TFD_TIMER_CANCEL_ON_SET.
1147311473
initial: long_long = 0
11474-
initial expiration timing in seconds.
11474+
initial expiration timing in nanoseconds.
1147511475
interval: long_long = 0
11476-
interval for the timer in seconds.
11476+
interval for the timer in nanoseconds.
1147711477

1147811478
Alter a timer file descriptor's internal timer in nanoseconds.
1147911479
[clinic start generated code]*/
1148011480

1148111481
static PyObject *
1148211482
os_timerfd_settime_ns_impl(PyObject *module, int fd, int flags,
1148311483
long long initial, long long interval)
11484-
/*[clinic end generated code: output=6273ec7d7b4cc0b3 input=261e105d6e42f5bc]*/
11484+
/*[clinic end generated code: output=6273ec7d7b4cc0b3 input=94bdcea7292157eb]*/
1148511485
{
1148611486
struct itimerspec new_value;
1148711487
struct itimerspec old_value;
@@ -11511,12 +11511,12 @@ os.timerfd_gettime
1151111511
A timer file descriptor.
1151211512
/
1151311513

11514-
Return a tuple of a timer file descriptor's (interval, next expiration) in float seconds.
11514+
Return a tuple of a timer file descriptor's (next expiration, interval) in float seconds.
1151511515
[clinic start generated code]*/
1151611516

1151711517
static PyObject *
1151811518
os_timerfd_gettime_impl(PyObject *module, int fd)
11519-
/*[clinic end generated code: output=ec5a94a66cfe6ab4 input=05f7d568a4820dc6]*/
11519+
/*[clinic end generated code: output=ec5a94a66cfe6ab4 input=7b0a7cc61ea9e31a]*/
1152011520
{
1152111521
struct itimerspec curr_value;
1152211522
int result;
@@ -11538,12 +11538,12 @@ os.timerfd_gettime_ns
1153811538
A timer file descriptor.
1153911539
/
1154011540

11541-
Return a tuple of a timer file descriptor's (interval, next expiration) in nanoseconds.
11541+
Return a tuple of a timer file descriptor's (next expiration, interval) in nanoseconds.
1154211542
[clinic start generated code]*/
1154311543

1154411544
static PyObject *
1154511545
os_timerfd_gettime_ns_impl(PyObject *module, int fd)
11546-
/*[clinic end generated code: output=580633a4465f39fe input=d0de95b9782179c5]*/
11546+
/*[clinic end generated code: output=580633a4465f39fe input=89702268455fa93b]*/
1154711547
{
1154811548
struct itimerspec curr_value;
1154911549
int result;

0 commit comments

Comments
 (0)