liveBook · Manning

Bounded queue

As explained in Python Concurrency with asyncio

A bounded queue is a queue configured with a finite maximum capacity for stored items.

A bounded queue limits how many items it can store. The upper bound prevents an application from accepting more work than it can hold; when the queue is full, coroutine-based insertion can wait instead of adding immediately. section 12.1

Limiting a customer line

A supermarket queue configured with Queue(maxsize=1) holds one customer. A second put_nowait call cannot add another item immediately, while await queue.put(customer) provides the waiting behavior needed when the line is full. The same queue may use await queue.get() so cashiers wait for customers when the line is empty.

How Python Concurrency with asyncio covers it

How deep it goes
Explains capacity limits and contrasts nonblocking methods with coroutine methods, without detailing queue internals.
Examples
Uses a supermarket customer line and an asyncio.Queue(maxsize=1) code example.
What it assumes
Assumes basic queues and asynchronous functions while establishing empty and full queue behavior through a practical example.
What you can do after
Operate/configure it by setting Queue(maxsize) and choosing immediate or waiting insertion and retrieval methods.
How it connects
Connects asynchronous queues with coroutines, blocking operations, nonblocking operations, and worker processes.

Also explained in

Compare how 3 books explain bounded queue →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python Concurrency with asyncio. The section links point to the parts of the book it draws on.