On Jun 10, 11:33 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > I'd like some feedback on a solution to a variant of the producer- > consumer problem. My first few attempts turned out to deadlock > occasionally; this one seems to be deadlock-free so far but I can't > tell if it's provably correct, and if so, whether it can be > simplified. > > The generic producer-consumer situation with unlimited buffer capacity > is illustrated athttp://docs.python.org/lib/condition-objects.html. > That approach assumes that the producer will keep producing items > indefinitely, otherwise the consumer ends up waiting forever. The > extension to the problem I am considering requires the consumer to be > notified not only when there is a new produced item, but also when > there is not going to be a new item so that it stops waiting.
Sounds like a sentinel would work for this. The producer puts a specific object (say, None) in the queue and the consumer checks for this object and stops consuming when it sees it. But that seems so obvious I suspect there's something else up. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list