#1
  1. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154

    How Accurate is Sleep


    I was just wondering how accurate time.sleep() really is. I've been told that in Visual Basic 6 the timer controls can be up to 4 milliseconds off every time you use them. In Python is time.sleep() off by any amount of time, even if its 1 millisecond?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    From the module docs, it looks like it can be off by any unknown amount of time every call:

    sleep( secs)
    Suspend execution for the given number of seconds. The argument may be a floating point number to indicate a more precise sleep time. The actual suspension time may be less than that requested because any caught signal will terminate the sleep() following execution of that signal's catching routine. Also, the suspension time may be longer than requested by an arbitrary amount because of the scheduling of other activity in the system.

IMN logo majestic logo threadwatch logo seochat tools logo