This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eckhardt
Recipients eckhardt
Date 2011-07-01.06:45:49
SpamBayes Score 2.559064e-14
Marked as misclassified No
Message-id <1309502750.92.0.889855315847.issue12459@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-07-01 06:45:51eckhardtsetrecipients: + eckhardt
2011-07-01 06:45:50eckhardtsetmessageid: <1309502750.92.0.889855315847.issue12459@psf.upfronthosting.co.za>
2011-07-01 06:45:50eckhardtlinkissue12459 messages
2011-07-01 06:45:49eckhardtcreate