Skip to content

Queue.get loses result on CancelledError  #2826

Open

Description

@robnagler

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.

Activity

  1. bdarnell commented on Nov 19, 2026

    @bdarnell
    Member

    Adding a note from #3770: That PR fixed cancellation issues for code that uses async with. Fixing a bare await lock.acquire() is trickier and hasn't been done yet; it should be done as a part of the queue work since await queue.get() has the same issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions