New submission from Ulrich Eckhardt <eckha...@satorlaser.com>:

For reference, see the thread on the users' mailinglist/newsgroup from 
2011-06-29 "how to call a function for evry 10 seconds" and the thread on the 
developers' mailinglist from 2011-06-30 "time.sleep(-1) behaviour".

The problem is how negative arguments to time.sleep() are handled. Python 2.x 
(tested 2.5 and 2.7) implementations on MS Windows seems to have a 32-bit 
underflow while converting the given argument to the DWORD that is passed to 
win32's Sleep() function. This causes a small negative value to sleep for a 
long time.

On Linux, using Python 2.6, you get an IOError instead. While an error is 
better than blocking effectively forever, the use of an IOError to signal the 
wrong argument is at least confusing. I guess it is an artifact of the 
implementation, but that shouldn't be visible prominently.

IMHH, both versions should raise a ValueError to signal invalid arguments. 
However, there was also the suggestion to simply treat negative values as zero, 
after all time.sleep() is already documented to possibly sleep longer than 
specified.

----------
messages: 139548
nosy: eckhardt
priority: normal
severity: normal
status: open
title: time.sleep(-1.0) behaviour
type: behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12459>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to