queue.LifoQueue()
queue.LifoQueue() is a Python function in the Queue Module category. Creates a LIFO (Last-In-First-Out) thread-safe queue (stack). The syntax is queue.LifoQueue(maxsize=0). Returns: LifoQueue object. A typical example: q = LifoQueue()
q.put(1); q.put(2)
q.get() # 2 (last in, first out). A close sibling is queue.Queue(), which creates a FIFO (First-In-First-Out) thread-safe queue. A close sibling is queue.PriorityQueue(), which creates a thread-safe priority queue (lowest value is retrieved first). A close sibling is Queue.put(), which puts an item into the queue. Blocks if full until space is available. A close sibling is Queue.get(), which removes and returns an item from the queue. Blocks if empty. More about this category: Thread-safe queues — Queue, LifoQueue, PriorityQueue, SimpleQueue. Related Queue Module entries: queue.Queue(), queue.PriorityQueue(), Queue.put(), Queue.get(), Queue.task_done(), Queue.join(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.