yielding control

Bengt Richter bokr at oz.net
Tue Oct 15 22:55:10 CEST 2002


On Wed, 16 Oct 2002 02:04:57 +0800, "Rob Hall" <bloke at ii.net> wrote:
[...]
>
>A call to sleep would slow down the script even when I am not using the
>computer for something else.  It was my first thought too.  I'm sure I read
>somewhere once that it can be done, but for the life of me can't remember
>where.
>
Is this what you were thinking of?

>From Win32 Programmers ref:
--
The Sleep function suspends the execution of the current thread
for a specified interval. 

VOID Sleep(
    DWORD  cMilliseconds 	// sleep time in milliseconds 
   );	

Parameters
cMilliseconds

Specifies the time, in milliseconds, for which to suspend execution.
A value of zero causes the thread to relinquish the remainder of its
time slice to any other thread of equal priority that is ready to run.
If there are no other threads of equal priority ready to run, the function
returns immediately, and the thread continues execution.
A value of INFINITE causes an infinite delay. 

Return Value

This function does not return a value. 

Remarks

A thread can relinquish the remainder of its time slice by calling this
function with a sleep time of zero milliseconds. 
--

I'm not sure whether time.sleep(0) will pass on a zero to win32 Sleep, but
it would seem reasonable. Int zero converts accurately to floating point zero
and back.

Regards,
Bengt Richter



More information about the Python-list mailing list