Lines Matching full:queue
1 """A multi-producer, multi-consumer queue."""
11 __all__ = ['Empty', 'Full', 'Queue', 'PriorityQueue', 'LifoQueue']
14 "Exception raised by Queue.get(block=0)/get_nowait()."
18 "Exception raised by Queue.put(block=0)/put_nowait()."
21 class Queue: class
22 """Create a queue object with a given maximum size.
24 If maxsize is <= 0, the queue size is infinite.
29 # mutex must be held whenever the queue is mutating. All methods
34 # Notify not_empty whenever an item is added to the queue; a
37 # Notify not_full whenever an item is removed from the queue;
48 Used by Queue consumer threads. For each get() used to fetch a task,
49 a subsequent call to task_done() tells the queue that the processing
54 for every item that had been put() into the queue).
57 placed in the queue.
71 """Blocks until all items in the Queue have been gotten and processed.
74 queue. The count goes down whenever a consumer thread calls task_done()
87 """Return the approximate size of the queue (not reliable!)."""
94 """Return True if the queue is empty, False otherwise (not reliable!)."""
101 """Return True if the queue is full, False otherwise (not reliable!)."""
108 """Put an item into the queue.
114 Otherwise ('block' is false), put an item on the queue if a free slot
143 """Put an item into the queue without blocking.
151 """Remove and return an item from the queue.
185 """Remove and return an item from the queue without blocking.
192 # Override these methods to implement other queue organizations
193 # (e.g. stack or priority queue).
196 # Initialize the queue representation
198 self.queue = deque()
201 return len(self.queue)
203 # Put a new item in the queue
205 self.queue.append(item)
207 # Get an item from the queue
209 return self.queue.popleft()
212 class PriorityQueue(Queue):
213 '''Variant of Queue that retrieves open entries in priority order (lowest first).
219 self.queue = []
222 return len(self.queue)
225 heappush(self.queue, item)
228 return heappop(self.queue)
231 class LifoQueue(Queue):
232 '''Variant of Queue that retrieves most recently added entries first.'''
235 self.queue = []
238 return len(self.queue)
241 self.queue.append(item)
244 return self.queue.pop()