reply.in.the.newsgroup at my.address.is.invalid
Wed Mar 22 01:57:41 CET 2006
>> Ah yes, clever trick. But you'd have to worry about thread-safety of your
>> subclass though.
>Queue worries about this for you. The Queue class only calls _get when
>it has the queue's mutex, so you can assume thread safety when
Ah yes, I overlooked the underscore. But you'd have to worry about
everything get() is doing before it calls _get() though :-)
>Say you were writing a FiniteQueue class that implemented the permament
>sentinel trick to indicate to all consumer threads that the queue is
>done. For your own code, you may know that you'll never need to pass
>None through the queue, but you can't assume that for all code.
Ah, this is where assert proves its value.
assert task is not None
self.numberOfTasks += 1
Wat wil jij leren? http://www.leren.nl
More information about the Python-list