Win32api,sleep() oddity

nealj mwarden22 at hotmail.com
Tue Jul 30 18:37:36 EDT 2002


The resolution of the Sleep function is controlled by the multimedia
timer (I know it doesn't make sense)  somewhere in your program's
initialization put:
timeBeginPeriod( 1 );

don't forget to call timeEndPeriod when your program is exiting..

I was never able to find any decent documentation on why this is - but
it works, right now, Sleep is returning with whatever resolution the
system is set to which I've seen as high as 200ms.

It appears that this only applies to NT/2K/XP based systems.

Good Luck!


Christopher.Cox at honeywell.com (Chris) wrote in message news:<13bf971.0207301012.3af0d16 at posting.google.com>...
> I use Python embedded in a testing utility on Windows NT4.  We
> recently switched PCs to a faster system because of the volume and
> intensity of the tests we were running.  The old system was a
> PIII-550MHz system and the new is a PIV-1.5GHz system.  We've noticed
> that when calling the following funtction:
> def wait(Seconds):
> 	loop = Seconds * 50
> 	for i in range (0,loop):
> 		win32api.Sleep(20)
> 		if win32ui.PumpWaitingMessages(0,-1):
> 			win32api.PostQuitMessage()
> 			raise exceptions.SystemExit
> 
> on the PIV system, the actual wait is 50% longer than we had requested
> (a 10 second wait actually waits 15.55 seconds, 100 seconds waits
> 155.5 seconds).  IS there some implementation detail in win32api that
> might cause this error to arise?  Any help would be appreciated.
> 
> Chris



More information about the Python-list mailing list