Python Glossary Русский

all Python 3queueexception

queue.Full

exceptions

The exception raised by put_nowait() and by put() with a timeout when a queue with maxsize is full.

Syntax

except queue.Full: ...

It only happens with maxsize > 0: by default a queue is unbounded and never full. A plain put() without a timeout does not raise Full; it blocks until space frees up. Catch it as queue.Full, since there is no builtin named Full, and the exception message is empty.

Examples

import queue
q = queue.Queue(maxsize=1)
q.put('a')
try:
    q.put_nowait('b')
except queue.Full as e:
    print('Full', repr(str(e)))  # → Full ''

See also

Open in the full glossarydocs.python.orgReport an inaccuracy