---
source: https://iinventedlight.com/library/notes/python-asyncio-queue.md
title: "Python asyncio queues: FIFO, priority, and LIFO queues for tasks"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, Queues; CPython, Queues documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-asyncio-queue"
tags: [python, asyncio, queue, fifo, task-done]
client: Librarian
sources:
  - id: S1
    title: "Queues"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/asyncio-queue.html
    accessed: 2026-11-26
    license: "PSF License Version 2"
  - id: S2
    title: "Queues documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/asyncio-queue.rst
    accessed: 2026-11-26
    license: "PSF License Version 2"
---
# Python asyncio queues: FIFO, priority, and LIFO queues for tasks
**Answer:** asyncio queues follow the queue module's shapes, but they are for async/await code and are not thread-safe.

## FIFO queues and size

The classes are designed to be similar to those in the queue module.

They are not thread-safe, and they are meant for async/await code.

Methods of asyncio queues don't have a timeout parameter; use the asyncio.wait_for() function to do queue operations with a timeout.

Queue is a first in, first out queue.

If maxsize is less than or equal to zero, the queue is considered infinite.

qsize() returns the current number of items, which is always known.

## Get, put, join, and shutdown

get removes and returns an item, waiting if the queue is empty.

It raises QueueShutDown if the queue was shut down and is empty, or if it was shut down immediately.

get_nowait returns an item if one is already there, otherwise it raises QueueEmpty.

put adds an item, waiting for a free slot if the queue is full, and it raises QueueShutDown after a shutdown.

put_nowait adds an item without blocking, or raises QueueFull when no slot is free.

The unfinished-task count rises when an item is added and falls when a consumer calls task_done to say work on that item is finished.

join blocks until every item has been received and processed, which is when that count drops to zero.

shutdown puts the queue into shutdown mode so it can no longer grow, and later put calls raise QueueShutDown.

PriorityQueue returns entries in priority order, lowest first, usually as (priority_number, data) tuples.

LifoQueue is a variant of Queue that retrieves most recently added entries first.

## See also

- [python-asyncio-basics](https://iinventedlight.com/library/notes/python-asyncio-basics/)
- [python-asyncio-taskgroup](https://iinventedlight.com/library/notes/python-asyncio-taskgroup/)
- [python-queue](https://iinventedlight.com/library/notes/python-queue/)

## Claims

- id: C1
  claim: asyncio queues are not thread-safe and are meant for async/await code.
  source: S1
  evidence: "they are designed to be used specifically in async/await code."

- id: C2
  claim: A Queue is first in, first out, and a non-positive maxsize means an infinite queue.
  source: S1
  evidence: "A first in, first out (FIFO) queue."

- id: C3
  claim: shutdown prevents the queue from growing and makes later put calls raise QueueShutDown.
  source: S2
  evidence: "The queue can no longer grow."

## Sources

- [S1] Queues. Python Software Foundation. https://docs.python.org/3/library/asyncio-queue.html . License: PSF License Version 2. Accessed 2026-11-26.

- [S2] Queues documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/asyncio-queue.rst . License: PSF License Version 2. Accessed 2026-11-26.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, Queues; CPython, Queues documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
