TaskQueue

Rene Pijlman reply.in.the.newsgroup at my.address.is.invalid
Tue Mar 21 18:23:30 CET 2006


Carl Banks:
>Rene Pijlman:
>>         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.

Ah yes, clever trick. But you'd have to worry about thread-safety of your
subclass though.

>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.)

You mean this post, I guess:
http://mail.python.org/pipermail/python-list/2004-October/244750.html

I dunno, but I cannot think of a better way to say "this has no possible
use" than to pass None. Place yourself in the position of someone who
doesn't know exactly what object() is and who encounters it in the code.
I've just spent 5 minutes trying to find some reference information and I
gave up ("object" is a lousy search word).

-- 
René Pijlman

Wat wil jij leren?  http://www.leren.nl



More information about the Python-list mailing list