GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — bpo-21302: Add clock_nanosleep() implementation for time.sleep() by Livius90 · Pull Request #28111 · python/cpython Conversation
|
I do not think that it is available in macOS and FreeBSD according the gnulib manual, clock_nanosleep() is available sure in Linux from POSIX version 2001.12. So any modern and new Linux based OS has it, moreover it seems to me QNX has also the same clock_nanosleep(). Is there any right place to mention this improved resolution of time.sleep()? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
PEP 7 rules appled for _PyTime_AsTimespec and _PyTime_AsTimeval error checking in pysleep().
In calling clock_nanosleep() EINTR is not stored in errno. Need to use return value of clock_nanosleep()/select() for checking it.
Unix operating systems eg: Linux, macOS, FreeBSD etc. time.sleep() has a resolution of nanoseconds with using clock_nanosleep() or nanosleep() function.
There was an error while loading. Please reload this page.
|
In all Unix systems eg: macOS, FreeBSD, Linux etc, nanosleep() is available and as i see there are some codes where select() is used for sleeping microsecs resolution, semaphore.c, _tkinter.c. Sleeping via select() was the state of the art solution in about 1998 in Linux but it is already an outdated solution nowadays. It would be better to use nanosleep() in these codes also. I will improve it in the rest of codes, too. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
In all Unix systems eg: macOS, FreeBSD, Linux etc, nanosleep() is available.
Waitable timer is 100 nsec resolution. Now, seconds to nanosec conversion is limited in usec, soon will come the next developing part to improve it in next commit.
Waitable timer resolution is 100 nsec but it is limited to 1 usec by round ceiling, moreover sleep for lower then 1 milisec is not possible in Win32 API.
There was an error while loading. Please reload this page.
|
Improved time.sleep() is ready for final review. All platforms have now the state of the art solution for sleeping. In Windows it uses Waitable timer object, in Linux it is clock_nanosleep() and in other Unix systems eg: macOS, FreeBSD it is nanosleep() function. Resolution of Waitable timer object is 100 nsec but it is limited to 1 usec by round ceiling. However, sleeping for lower than 1 millisec is not possible in Win32 API because the overhead of the the event waiting call is more than nanoseconds. Resolution of clock_nanosleep() and nanosleep() is 1 nsec, clock_nanosleep() is suitable for blocking/waiting until an absolute time date, nanosleep() is suitable only for interval sleeping. @abalkin, @pganssle and @vstinner please make a review for my final state. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Can not simplify HAVE_CLOCK_NANOSLEEP blocks because do {} while loop need for EINTR error handling
|
Merged, thanks! I created PR #28311 follow-up to update the documentation. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks the merging. What are the formal rules to create a new PR to improve Windows implementation, too? Is it good to create a new PR without any bpo issue number? Or can i make more PR (windows implementation and nanosleep()) for this bpo-21302? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
In this case, you can reuse bpo-21302. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.