Skip to content

queues: Preserve items when waiting consumers are canceled - #3689

Open
Sanjays2402 wants to merge 1 commit into
tornadoweb:masterfrom
Sanjays2402:fix/queue-cancel-preserve-item
Open

queues: Preserve items when waiting consumers are canceled#3689
Sanjays2402 wants to merge 1 commit into
tornadoweb:masterfrom
Sanjays2402:fix/queue-cancel-preserve-item

Conversation

@Sanjays2402

Copy link
Copy Markdown

Fixes #2826.

A queue item can be assigned to a waiting getter just before its consumer task is canceled; cancellation then replaces the getter's completed result and silently drops the item. Queue getters now return completed items to the queue when cancellation wins that race, without changing the unfinished-task count.

The regression test reproduces the put-then-cancel ordering: it fails with QueueEmpty before the fix and passes afterward. The queues test module passes all 43 tests.

Queue.put_nowait resolves a waiting getter before its consumer task resumes.
If that task is canceled in the gap, cancellation replaces the delivered
result and the item disappears.

Use a cancellation-aware getter future to return a delivered item to the
queue when cancellation wins that race. Add regression coverage for the
put-then-cancel ordering.

Fixes tornadoweb#2826.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Queue.get loses result on CancelledError

1 participant