Threading and Conditions

Gordon McMillan gmcm at hypernet.com
Wed Mar 22 21:25:43 EST 2000


Ken Seehof wrote:

> Gordon McMillan wrote:
> 
> > Ken Seehof wrote:
> >
> > . . .
> > > Unfortunately, the documentation is inadequate.  Does anyone know of a
> > > whole sample program using conditions?
> >
> > The test code at the bottom of the module.
> 
> That's the inadequate documentation I was talking about.  This "example"would
> be much better if it showed the whole interaction, including creating the
> threads and conditions.  An example should be a working script that
> demonstrates a feature. Anyway, I did manage to get it to work.
> 
> Here's the "example":
> 
>      # Consume one item
>      cv.acquire()
>      while not an_item_is_available():
>          cv.wait()
>      get_an_available_item()
>      cv.release()
> 
>      # Produce one item
>      cv.acquire()
>      make_an_item_available()
>      cv.notify()
>      cv.release()

Where did you get your threading module? For 1.5.2, the test 
code begins at line 550 and extends to the end (line 638) and 
is a complete test program. The lines you quote aren't even 
part of it.


- Gordon




More information about the Python-list mailing list