tornadoweb / tornadoweb/tornado

IOStream._handle_write blocks when _write_buffer is large

Open
#2,110 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When dumping a gigabyte or so into an IOStream I observe my event loop pausing for long periods of time (about a second). I believe that this is due to long atomic calls to _handle_write that continue looping while the _write_buffer still has data. This can cause some unpleasant blocking in the application.

Is it feasible to have _handle_write yield from time to time during large writes?

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 by locating IOStream._handle_write and trace how it drains _write_buffer within the event loop. Reproduce the reported pause with a roughly gigabyte-sized write, then inspect existing IOStream tests for buffering and write scheduling. Done means large writes no longer block the event loop for long periods and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.