[Python-Dev] time.sleep(-1) behaviour
ncoghlan at gmail.com
Fri Jul 1 14:46:16 CEST 2011
On Fri, Jul 1, 2011 at 10:17 PM, Tim Lesher <tlesher at gmail.com> wrote:
> On Thu, Jun 30, 2011 at 15:13, Ulrich Eckhardt
> <ulrich.eckhardt at dominolaser.com> wrote:
>> This is a request for clarification for the thread "how to call a function for
>> evry 10 seconds" from the user mailinglist/newsgroup.
>> The gist is this:
>> 1. On Linux/Python 2.6, time.sleep(-1.0) raises an IOError.
>> 2. On MS Windows/Python 2.5 or 2.7 this sleeps forever. It seems that
>> converting this to a 32-bit integer for Sleep() causes an underflow.
>> 3. Is the behaviour under MS Windows acceptable or a bug?
> On the Windows side, Sleep(-1) as "infinite" is correct and documented:
For Sleep, yes, but the time.sleep() docs  are completely silent on
the behaviour of negative sleep values at the Python level. Question 3
isn't "Is there something wrong with Sleep()?", it is "Is there
something wrong with the way time.sleep() *uses* Sleep()?"
My personal preference would be to standardise on ValueError (since
the negative sleep value is the real problem), or, failing that, at
least raising an exception of some kind.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev