> Your solution works assuming that you know how many consumer threads > you have :). I don't :). More than that, it's not correct if you have > more than one producer :). Having a sentinel was my very first idea, > but as you see... it's a race condition (there are cases in which not > all items are processed).
Queue raises an Empty exception when there are no items left in the queue. Put the q.get() call in a try block and exit in the except block. You can also use a condition variable to signal threads to terminate. -- http://mail.python.org/mailman/listinfo/python-list