asyncio.Queue coordinates asynchronous workers through a first-in-first-out line of work items. Producers add items, while worker tasks retrieve them and process them concurrently without blocking the event loop. section 12.1
The queue supports two styles of retrieval and insertion:
- Use get_nowait() and put_nowait() for immediate operations; an empty queue or a full bounded queue raises an error. section 12.1
- Call task_done() after processing each retrieved item so queue.join() can track when all unfinished work is complete. section 12.1
Supermarket checkout
Represent customers as work items and cashiers as worker tasks. Each cashier awaits a customer, processes its products, and sleeps for each product's checkout time. Several cashiers can therefore handle different customers while the queue preserves arrival order. section 12.1
