On this page
queue.SimpleQueue
Prev: queue.ShutDown | Up: queue
Rel: queue.Empty, queue.Full, queue.LifoQueue, queue.PriorityQueue
Ref: docs.python.org — queue.SimpleQueue
Tags: #public #python3 #stdlib #queue
Import
import queue
from queue import SimpleQueue
Signature & Overview
queue.SimpleQueue()
Simple, unbounded, reentrant FIFO queue.
Methods & Attributes
SimpleQueue.empty(self, /)— Return True if the queue is empty, False otherwise (not reliable!).SimpleQueue.get(self, /, block=True, timeout=None)— Remove and return an item from the queue.SimpleQueue.get_nowait(self, /)— Remove and return an item from the queue without blocking.SimpleQueue.put(self, /, item, block=True, timeout=None)— Put the item on the queue.SimpleQueue.put_nowait(self, /, item)— Put an item into the queue without blocking.SimpleQueue.qsize(self, /)— Return the approximate size of the queue (not reliable!).
Usage
import queue
sq: queue.SimpleQueue[int] = queue.SimpleQueue()
sq.put(10)
sq.put(20)
assert sq.get() == 10 and sq.get() == 20
Gotchas
- Re-entrant C implementation: Safer inside signal handlers or
__del__finalizers, but unbounded and lackstask_done()/join().
REPL Inspect
from queue import SimpleQueue
help(SimpleQueue)
Linked from
Related notes
- tuts/python3/stdlib_module/queue/ShutDown Linked here; links to this page; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/Empty Linked here; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/Full Linked here; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/LifoQueue Linked here; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/PriorityQueue Linked here; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/Queue Linked here; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib