Skip to content

Commit 13ab4c2

Browse files
Fix various issues in the 'Timer File Descriptors' documentation (#156027)
Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent 5f31aee commit 13ab4c2

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

45794579
If *clockid* is :const:`time.CLOCK_REALTIME`, a settable system-wide
4580-
real-time clock is used. If system clock is changed, timer setting need
4581-
to be updated. To cancel timer when system clock is changed, see
4580+
real-time clock is used. If the system clock is changed, the timer setting
4581+
needs to be updated. To cancel the timer when the system clock is changed, see
45824582
:const:`TFD_TIMER_CANCEL_ON_SET`.
45834583

45844584
If *clockid* is :const:`time.CLOCK_MONOTONIC`, a non-settable monotonically
45854585
increasing clock is used. Even if the system clock is changed, the timer
45864586
setting will not be affected.
45874587

4588-
If *clockid* is :const:`time.CLOCK_BOOTTIME`, same as :const:`time.CLOCK_MONOTONIC`
4589-
except it includes any time that the system is suspended.
4588+
If *clockid* is :const:`time.CLOCK_BOOTTIME`, it is the same as
4589+
:const:`time.CLOCK_MONOTONIC` except it includes any time that the system
4590+
is suspended.
45904591

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

45984599
If :const:`TFD_NONBLOCK` is not set as a flag, :func:`read` blocks until
45994600
the timer expires. If it is set as a flag, :func:`read` doesn't block, but
4600-
If there hasn't been an expiration since the last call to read,
4601-
:func:`read` raises :class:`OSError` with ``errno`` is set to
4601+
if there hasn't been an expiration since the last call to read,
4602+
:func:`read` raises :class:`OSError` with ``errno`` set to
46024603
:const:`errno.EAGAIN`.
46034604

46044605
:const:`TFD_CLOEXEC` is always set by Python automatically.
@@ -4613,7 +4614,7 @@ Naturally, they are all only available on Linux.
46134614
.. versionadded:: 3.13
46144615

46154616

4616-
.. function:: timerfd_settime(fd, /, *, flags=flags, initial=0.0, interval=0.0)
4617+
.. function:: timerfd_settime(fd, /, *, flags=0, initial=0.0, interval=0.0)
46174618

46184619
Alter a timer file descriptor's internal timer.
46194620
This function operates the same interval timer as :func:`timerfd_settime_ns`.
@@ -4628,12 +4629,11 @@ Naturally, they are all only available on Linux.
46284629
- :const:`TFD_TIMER_CANCEL_ON_SET`
46294630

46304631
The timer is disabled by setting *initial* to zero (``0``).
4631-
If *initial* is equal to or greater than zero, the timer is enabled.
4632+
If *initial* is greater than zero, the timer is enabled.
46324633
If *initial* is less than zero, it raises an :class:`OSError` exception
4633-
with ``errno`` set to :const:`errno.EINVAL`
4634+
with ``errno`` set to :const:`errno.EINVAL`.
46344635

46354636
By default the timer will fire when *initial* seconds have elapsed.
4636-
(If *initial* is zero, timer will fire immediately.)
46374637

46384638
However, if the :const:`TFD_TIMER_ABSTIME` flag is set,
46394639
the timer will fire when the timer's clock
@@ -4644,13 +4644,13 @@ Naturally, they are all only available on Linux.
46444644
If *interval* is greater than zero, the timer fires every time *interval*
46454645
seconds have elapsed since the previous expiration.
46464646
If *interval* is less than zero, it raises :class:`OSError` with ``errno``
4647-
set to :const:`errno.EINVAL`
4647+
set to :const:`errno.EINVAL`.
46484648

46494649
If the :const:`TFD_TIMER_CANCEL_ON_SET` flag is set along with
46504650
:const:`TFD_TIMER_ABSTIME` and the clock for this timer is
46514651
:const:`time.CLOCK_REALTIME`, the timer is marked as cancelable if the
46524652
real-time clock is changed discontinuously. Reading the descriptor is
4653-
aborted with the error ECANCELED.
4653+
aborted with the error :const:`errno.ECANCELED`.
46544654

46554655
Linux manages system clock as UTC. A daylight-savings time transition is
46564656
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
@@ -11484,17 +11484,17 @@ os.timerfd_settime_ns
1148411484
flags: int = 0
1148511485
0 or a bit mask of TFD_TIMER_ABSTIME or TFD_TIMER_CANCEL_ON_SET.
1148611486
initial: long_long = 0
11487-
initial expiration timing in seconds.
11487+
initial expiration timing in nanoseconds.
1148811488
interval: long_long = 0
11489-
interval for the timer in seconds.
11489+
interval for the timer in nanoseconds.
1149011490

1149111491
Alter a timer file descriptor's internal timer in nanoseconds.
1149211492
[clinic start generated code]*/
1149311493

1149411494
static PyObject *
1149511495
os_timerfd_settime_ns_impl(PyObject *module, int fd, int flags,
1149611496
long long initial, long long interval)
11497-
/*[clinic end generated code: output=6273ec7d7b4cc0b3 input=261e105d6e42f5bc]*/
11497+
/*[clinic end generated code: output=6273ec7d7b4cc0b3 input=94bdcea7292157eb]*/
1149811498
{
1149911499
struct itimerspec new_value;
1150011500
struct itimerspec old_value;
@@ -11524,12 +11524,12 @@ os.timerfd_gettime
1152411524
A timer file descriptor.
1152511525
/
1152611526

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

1153011530
static PyObject *
1153111531
os_timerfd_gettime_impl(PyObject *module, int fd)
11532-
/*[clinic end generated code: output=ec5a94a66cfe6ab4 input=05f7d568a4820dc6]*/
11532+
/*[clinic end generated code: output=ec5a94a66cfe6ab4 input=7b0a7cc61ea9e31a]*/
1153311533
{
1153411534
struct itimerspec curr_value;
1153511535
int result;
@@ -11551,12 +11551,12 @@ os.timerfd_gettime_ns
1155111551
A timer file descriptor.
1155211552
/
1155311553

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

1155711557
static PyObject *
1155811558
os_timerfd_gettime_ns_impl(PyObject *module, int fd)
11559-
/*[clinic end generated code: output=580633a4465f39fe input=d0de95b9782179c5]*/
11559+
/*[clinic end generated code: output=580633a4465f39fe input=89702268455fa93b]*/
1156011560
{
1156111561
struct itimerspec curr_value;
1156211562
int result;

0 commit comments

Comments
 (0)