tornadoweb / tornadoweb/tornado

Queue.get loses result on CancelledError

Open
#2,826 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

queues
Dominant language
Python
Stars
22.2k
Forks
5.6k
Avg merge
3h 42m
Merged PRs (30d)
16

Description

I realize that Tornado doesn't support cancelling. I thought I'd document this issue anyway, since it caused a server hang in our app, and was tricky to debug.

If the task waiting on a queue gets cancelled, the result of the future is lost. put_nowait pulls off the queue item and get does not catch CancelledError. When the task is cancelled, the queue item is lost.

We have worked around this by catching CancelledError in subclass of Queue. If there's a future result, it puts it back in the queue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in tornado/queues.py at the put_nowait and get locations linked in the issue, then review the cancellation behavior described there. Reproduce the lost queue item and determine the expected behavior for a cancelled waiter; done would require an agreed behavior and regression coverage, but the issue does not specify the intended fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.