tornadoweb / tornadoweb/tornado

on_finish() is not called when the client closed first.

Open
#517 6 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

class Webbench(tornado.web.RequestHandler):
count = 0
fini_count = 0;
closed_count = 0;

@tornado.web.asynchronous
def get(self, *args, **kwargs):
    Webbench.count += 1
    logging.debug("Webbench client count %d" % Webbench.count)

    self.write("hello world " + str(Webbench.count))
    // the finish() cause on_finish() being called.
    // self.finish()

def on_finish(self):
    Webbench.fini_count += 1
    logging.debug("Webbench finished %d, closed %d, total %d" 
                  % (Webbench.fini_count, Webbench.closed_count, Webbench.count))

def on_connection_close(self):
    // when client reset or closed connection, the on_finish() was not called.
    tornado.web.RequestHandler.on_connection_close(self)

    Webbench.closed_count += 1
    logging.debug("Webbench closed %d, finished %d, total %d" 
                  % (Webbench.closed_count, Webbench.fini_count, Webbench.count))

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 with tornado.web.RequestHandler.on_finish and on_connection_close, then trace the request cleanup path when the client closes first. Reproduce the Webbench example and add a regression test that makes the expected callback behavior explicit.

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.