tornadoweb / tornadoweb/tornado
Queue.get loses result on CancelledError
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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