Rene Pijlman wrote:
> >2) complicating the producer logic to append one sentinel for each consumer
> >when the data stream is done
>
>         for i in range(self.numberOfThreads):
>             self.workQueue.put(None)

Or, you could just put one sentinel in the Queue, and subclass the
Queue's _get method not to take the sentinel out.  It might help keep
bookkeeping down (and it seems Raymond was in a situation where keeping
track of threads wasn't so easy).

BTW, for sentinels, I recommend creating one using:

sentinel = object()

Because, although it's not applicable to your example, sometimes None
is an object you want to pass through.  (I think Alex Martelli came up
with that one.)

Carl Banks

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to