[Python-Dev] time.sleep(-1) behaviour
victor.stinner at haypocalc.com
Thu Jun 30 22:11:42 CEST 2011
Le jeudi 30 juin 2011 à 21:13 +0200, Ulrich Eckhardt a écrit :
> 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.
select.select() was changed recently to raise an exception if the
timeout is negative to get the same behaviour on all platforms.
signal.sigtimedwait() (recently added function) raises also an exception
if the timeout is negative.
If it's an overflow, Python should raise an OverflowError, or raise
another error, but not sleep for 2^32-1 (or 2^64-1 ?) seconds.
More information about the Python-Dev