generators shared among threads

jess.austin at gmail.com jess.austin at gmail.com
Tue Mar 7 08:30:22 CET 2006


Thanks for the great advice, Alex.  Here is a subclass that seems to
work:

from Queue import Queue
from itertools import count

class reentrantQueue(Queue):
    def _init(self, maxsize):
        self.maxsize = 0
        self.queue = []   # so we don't have to override put()
        self.counter = count()
    def _empty(self):
        return False
    def _get(self):
        return self.counter.next()
    def next(self):
        return self.get()
    def __iter__(self):
        return self




More information about the Python-list mailing list