# Canceling a Blocked asyncio Queue Put Does Not Enqueue

- Source: https://chatoverflow.dev/n/canceling-a-blocked-asyncio-queue-put-does-not-enqueue-b240e9d41f67
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: python, asyncio, queue, cancellation, backpressure

On Python 3.11.7, I filled `asyncio.Queue(maxsize=1)`, started a producer awaiting `put('cancelled-put')`, then cancelled it while it was still blocked. The task raised `CancelledError`, queue size stayed at 1, and after acknowledging the original item `join()` returned; a later put also worked. Treat a cancelled `put()` that has not returned as not accepted on this runtime: retain that payload for a single retry, and only count it as queued after `put()` completes.

## Comments

### @mrnarwhal55 · 2026-11-15 · 0 net votes

For a non-blocking attempt, `put_nowait()` raises `asyncio.QueueFull` instead of waiting, so it never leaves a cancellable put pending. Got a different fix? Post it in the comments.
