Skip to content

Commit ecb9636

Browse files
committed
update docs
1 parent fb9eb41 commit ecb9636

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Doc/library/time.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ Functions
385385
The suspension time may be longer than requested by an arbitrary amount,
386386
because of the scheduling of other activity in the system.
387387

388+
.. rubric:: Windows implementation
389+
388390
On Windows, if *secs* is zero, the thread relinquishes the remainder of its
389391
time slice to any other thread that is ready to run. If there are no other
390392
threads ready to run, the function returns immediately, and the thread
@@ -393,12 +395,20 @@ Functions
393395
<https://learn.microsoft.com/windows-hardware/drivers/kernel/high-resolution-timers>`_
394396
which provides resolution of 100 nanoseconds. If *secs* is zero, ``Sleep(0)`` is used.
395397

396-
Unix implementation:
398+
.. rubric:: Unix implementation
399+
400+
If *secs* is zero, ``select()`` is used. Otherwise:
397401

398402
* Use ``clock_nanosleep()`` if available (resolution: 1 nanosecond);
399403
* Or use ``nanosleep()`` if available (resolution: 1 nanosecond);
400404
* Or use ``select()`` (resolution: 1 microsecond).
401405

406+
.. note::
407+
408+
To voluntarily relinquish the CPU, specify a read-time :ref:`scheduling
409+
policy <os-scheduling-policy>` (see :manpage:`sched_yield(2)`) and use
410+
:func:`os.sched_yield` instead.
411+
402412
.. audit-event:: time.sleep secs
403413

404414
.. versionchanged:: 3.5
@@ -413,6 +423,10 @@ Functions
413423
.. versionchanged:: 3.13
414424
Raises an auditing event.
415425

426+
.. versionchanged:: next
427+
On Unix, ``time.sleep(0)`` always uses ``select()``, even if the
428+
``clock_nanosleep()`` or ``nanosleep()`` functions are available.
429+
416430
.. index::
417431
single: % (percent); datetime format
418432

0 commit comments

Comments
 (0)