[python-win32] sleep() for less than .001s?

Gabriel Genellina gagsl-p32 at yahoo.com.ar
Fri Aug 4 11:59:34 CEST 2006


At Thursday 3/8/2006 22:45, Ray Schumacher wrote:

>I have been trying to use sleep() and 
>kernel32.QueryPerformanceCounter together; I want to delay until a 
>particular tick without trying up the CPU badly.
>However, while time.sleep(.001) relieves the CPU, it has wildly 
>unpredictable delay, and sleep(.0001) delays almost nothing at all! 
>(I'm watching the parallel port on a scope).
>If I use a while and just count ticks with 
>QueryPerformanceCounter(), it is very stable and as desired - but it 
>uses 100% CPU.

I'm not sure if this really works, but you could try:
- Raise your thread/process's priority using SetPriorityClass or 
SetThreadPriority. This is to minimize the (unpredictable) delay of sleep()
- Keep your qPC loop, but insert a sleep(0) call, this would free the CPU.



Gabriel Genellina
Softlab SRL 


	
	
		
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas



More information about the Python-win32 mailing list