threading question

Ben Wolfson rumjuggler at cryptarchy.org
Sun May 14 16:48:40 EDT 2000


On Sun, 14 May 2000 20:15:38 +0200, Niels Diepeveen
<niels at endea.demon.nl> wrote:

>
>
>Ben Wolfson schreef:
>>     cond.notify() #so this should wake thread '2'
>>     cond.release()#and this should allow it to acquire the condition
>>                   #allowing it to break out of the loop.  When it
>>                   #calls notify(), nothing should happen, and then
>>                   #it should release.  Instead, thread '2' never
>>                   #acquires the condition in the first place
>>                   #once thread '1' reaches this point.
>
>By the time thread '1' gets here it has already called cond.acquire() 5
>times, so calling cond.release() just once isn't actually going to
>release anything. Then thread '1' will terminate while still owning the
>lock, so thread '2' will have to wait forever.

Ah.  I was under the impression that calling wait() counted as a
relese.

>BTW, don't you think that this is a rather complicated way to emulate
>coroutines?

I might if I knew what they were.

-- 
Barnabas T. Rumjuggler

There is only one place, and that place is time.
 -- Russell Hoban, _The Lion of Boaz-Jachin and Jachin-Boaz_



More information about the Python-list mailing list