how to call a function for evry 10 secs

Ian Kelly ian.g.kelly at gmail.com
Thu Jun 30 13:42:54 EDT 2011


On Thu, Jun 30, 2011 at 11:18 AM, MRAB <python at mrabarnett.plus.com> wrote:
>>        And that was a direct cut&paste from a command window; showing it
>> had slept for some 90 seconds before I killed it.
>>
> Looks like it hasn't changed even in WinXP, Python 3.2.

It gets cast to an unsigned long, so I expect sleep(-1) on Windows
would sleep for 2 ** 32 - 1000 ms, or about 49.7 days.

More interestingly, sleep(-0.001) should pass 2**32 - 1 to the
underlying Windows API, which would cause it to sleep forever (or
until interrupted).

> Is IOError what you'd expect, anyway?
>
> What should it do in Python 3.2? Exception or max(seconds, 0)?

sleep(0) has some special semantics on Windows.  Raising ValueError
(or IOError to match Linux) makes the most sense to me.

Cheers,
Ian



More information about the Python-list mailing list