New submission from Ben Bass <benpaulb...@googlemail.com>: Many applications would benefit from 'connectionless' queues, i.e. they don't want to care whether anything is reading from the other end. Using current queue module classes this is not practical, because there is a choice between unbounded memory consumption or blocking. I propose adding a 'LossyQueue' class in the queue module which would allow bounded memory consumption without blocking on put. (i.e. items are dropped in fifo manner beyond a certain limit). In my view this is at least as natural as the PriorityQueue and LifoQueue extensions in that module.
Outline as follows: class LossyQueue(Queue): "Queue subclass which drops items on overflow" def _init(self, maxsize): if maxsize > 0: # build the deque with maxsize limit self.queue = deque(maxlen=maxsize) else: # same as normal Queue instance self.queue = collections.deque() # deque alone handles maxsize, # so we pretend we have none self.maxsize = 0 if there is interest in this I will offer a proper patch with docs and tests. ---------- components: Library (Lib) messages: 95374 nosy: bpb severity: normal status: open title: Add lossy queue to queue library module type: feature request versions: Python 2.7, Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7337> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com