newbie question on threading
hunj
lei_pku at hotmail.com
Sun Oct 13 03:02:12 EDT 2002
Obviously, if a busy loop were used, how to end the process?
"Gonçalo Rodrigues" <op73418 at mail.telepac.pt> wrote in message
news:jsngquskdhc0cpg867djcna0cl6u8tlm9l at 4ax.com...
> Hi,
>
> I have another, very naive, question on the threading model. It is about
> 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