Threading and Conditions

Ken Seehof kens at sightreader.com
Thu Mar 23 00:02:16 EST 2000


Gordon McMillan wrote:

> 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

I was looking at the help file, not the module.

However perhaps I -should- have been looking at the module.  The _test()
function you are refering to is exactly what I needed.

- Ken






More information about the Python-list mailing list