tornadoweb / tornadoweb/tornado

StaticFileHandler block the whole application when downloading a large file

Open
#2,997 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Env: Tornado 6.1
When I download a 1GB file, the whole web application is blocked.

The code shows this await won't switch to other coroutines.
https://github.com/tornadoweb/tornado/blob/6cdf82e927d962290165ba7c4cccb3e974b541c3/tornado/web.py#L2648

after add

   await asyncio.sleep(0)

the blocking-method dismissed.

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/web.py at the StaticFileHandler code around line 2648, then inspect how the large-file download awaits its work. Reproduce a 1GB download alongside another request and verify that the application remains responsive while the file is served.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.