Threading modeule and condition??

Ishwar Rattan rattan at cps.cmich.edu
Fri Jul 23 15:33:01 EDT 2004


System is Mandrake-9.1 with Python-2.3.4

I need to learn condition variables (mentioned in Section 7.5.3 of library
reference) but I am confused on the way of creating one. The documentation
says:
---
# Produce one item
    cv.acquire()
    make_an_item_available()
    cv.notify()
    cv.release()

To choose between notify() and notifyAll(), consider whether one state
change can be interesting for only one or several waiting threads. E.g. in
a typical producer-consumer situation, adding one item to the buffer only
needs to wake up one consumer thread. 

class Condition([lock])

      If the lock argument is given and not None, it must be a Lock or RLock
object, and it is used as the underlying lock. Otherwise, a new RLock object
is created and used as the underlying lock. 
---

how do I insttantiate 'cv' the condition object in the first place. A code
fragment will be helpful.

-ishwar



More information about the Python-list mailing list