yielding control

sismex01 at hebmex.com sismex01 at hebmex.com
Tue Oct 15 22:33:15 CEST 2002


> From: JXStern [mailto:JXSternChangeX2R at gte.net]
> 
> 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.
> 
> I thought someone suggested a Yield() function (as in Visual Basic),
> but it doesn't appear in my doc.  How about a sleep of zero seconds?
> 
> J.
>

There's a yield in python, but it's for generators, and it's
more like an "intermediate" return (yields next value and
suspends the generator).

A sleep(0) gets skipped, IIRC.

Better do a sleep(0.0001), the OS get's a hold of the cpu,
and the actual sleep time is so small as to be almost zero.

-gus




More information about the Python-list mailing list