On this page
queue.Empty
Up: queue | Next: queue.Full
Rel: queue.Full, queue.LifoQueue, queue.PriorityQueue, queue.Queue
Ref: docs.python.org โ queue.Empty
Tags: #public #python3 #stdlib #queue
Import
import queue
from queue import Empty
Signature & Overview
queue.Empty(...)
Exception raised by Queue.get(block=0)/get_nowait().
Methods & Attributes
Empty.add_note(self, note, /)โ Add a note to the exceptionEmpty.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import queue
q: queue.Queue[int] = queue.Queue()
try:
q.get_nowait()
except queue.Empty:
assert True
Gotchas
- Raised by
get_nowait()orget(timeout=...)when no item arrives: Always catchqueue.Emptywhen polling a queue.
REPL Inspect
from queue import Empty
help(Empty)
Linked from
Related notes
- tuts/python3/stdlib_module/queue/Full Linked here; links to this page; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/LifoQueue Linked here; links to this page; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/PriorityQueue Linked here; links to this page; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/Queue Linked here; links to this page; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/ShutDown links to this page; shared tags: #queue, #stdlib
- tuts/python3/stdlib_module/queue/SimpleQueue links to this page; 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