newbie question on threading

Gonçalo Rodrigues op73418 at mail.telepac.pt
Sat Oct 12 14:06:06 EDT 2002


On Sat, 12 Oct 2002 18:50:09 +0100, Gonçalo Rodrigues
<op73418 at mail.telepac.pt> wrote:

>Hi,
>
>I have another, very naive, question on the threading model. It is about

<bonks himself on the head> It is not model, it is module <\bonks
himself on the head again>

>the condition object and the wait method. I have read the code, and the
>main loop is commented thus (in part):
>
>#Balancing act: We can't afford a pure busy loop, so we
>#have to sleep; but if we sleep the whole timeout time,
>#we'll be unresponsive.
>
>My question is: why is a busy loop not affordable (without a sleep
>call), e.g. something like (in pseudo-code description)
>
>while 1:
>    <acquire lock>
>    if <acquire sucessfull>:
>        break
>    if <timedout?>:
>        break
>    <calculate endtime>
>
>Thanks in advance,
>Gonçalo Rodrigues




More information about the Python-list mailing list