Author vstinner
Recipients akira, shankarunni, vstinner, yselivanov
Date 2014-04-26.23:59:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1398556786.4.0.0243407245973.issue21302@psf.upfronthosting.co.za>
In-reply-to
Content
If you want to modify time.sleep(), you must be careful of the portability: Windows, Linux, but also Mac OS X, FreeBSD, Solaris, etc.

Try to describe the behaviour of each underlying C function on each platform to be able to describe the "portable behaviour" on all platforms, especially the expected behaviour when the system clock is changed (is time.sleep impacted or not? always?) and the expected behaviour when the system is suspended.

For example, it looks like nanosleep() uses a different clock depending on OS (Linux uses CLOCK_MONOTONIC, other UNIX platforms use CLOCK_REALTIME).
http://lists.gnu.org/archive/html/bug-coreutils/2012-08/msg00087.html

I know that you suggest to use clock_nanosleep(), but this function is not available on all platforms. For example, I would not use it on Windows.

Another example (on Fedora?): "sleep() ignores time spent with a suspended system"
http://mjg59.dreamwidth.org/7846.html

You should also decide how to handle interrupted sleep (C error "EINTR"). Currently, the sleep is interrupted, no error is raised.

I began to describe all these functions in the PEP 418, even if I didn't change the implementation with the PEP:
http://legacy.python.org/dev/peps/pep-0418/#sleep
History
Date User Action Args
2014-04-26 23:59:46vstinnersetrecipients: + vstinner, akira, yselivanov, shankarunni
2014-04-26 23:59:46vstinnersetmessageid: <1398556786.4.0.0243407245973.issue21302@psf.upfronthosting.co.za>
2014-04-26 23:59:46vstinnerlinkissue21302 messages
2014-04-26 23:59:44vstinnercreate