facebook/tornado — pull request #510 by soluwalana (2012-05-11 05:09:01+00:00)
Title: Timing Issue in web.py/httpserver.py

Timing issue with web.py
It was possible to have _finish_request called twice with the same
request but then fails because the request is set to None.

Example:
From web.py 686
self.flush()
self.request.finish()

self.flush calls the HTTPConnections write which trigers the
_on_write_complete callback

Simultaneously self.request.finish() lands on line 189 of httpserver
self._request_finished = True

Then the callback is executed and falls through to self._finish_request()
Then self._finish_request() is called on line 191 of httpserver

This gives a ton of None Type doesn't have attribute errors.

Running self.request.finish as a callback in web.py 687 ensures that
self._request_finished == False on line 205 of httpserver