bpo-21302: Add nanosleep() implementation for time.sleep() in Unix (GH-28545)

Co-authored-by: Livius <egyszeregy@freemail.hu>
This commit is contained in:
Victor Stinner 2021-09-25 14:36:26 +02:00 committed by GitHub
parent 71f8ff45c6
commit 7834ff26cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 114 additions and 33 deletions

View file

@ -364,16 +364,18 @@ Functions
threads ready to run, the function returns immediately, and the thread
continues execution.
Implementation:
Unix implementation:
* On Unix, ``clock_nanosleep()`` is used if available (resolution: 1 ns),
or ``select()`` is used otherwise (resolution: 1 us).
* On Windows, a waitable timer is used (resolution: 100 ns). If *secs* is
zero, ``Sleep(0)`` is used.
* Use ``clock_nanosleep()`` if available (resolution: 1 ns);
* Or use ``nanosleep()`` if available (resolution: 1 ns);
* Or use ``select()`` (resolution: 1 us).
On Windows, a waitable timer is used (resolution: 100 ns). If *secs* is
zero, ``Sleep(0)`` is used.
.. versionchanged:: 3.11
On Unix, the ``clock_nanosleep()`` function is now used if available.
On Windows, a waitable timer is now used.
On Unix, the ``clock_nanosleep()`` and ``nanosleep()`` functions are now
used if available. On Windows, a waitable timer is now used.
.. versionchanged:: 3.5
The function now sleeps at least *secs* even if the sleep is interrupted