tornado: Ignore StreamClosedError.

This was also hidden until 81f7192ca3
(#22301).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-06-27 14:53:09 -07:00 committed by Tim Abbott
parent 0d93ec6214
commit 4fc3845dc2
1 changed files with 7 additions and 1 deletions

View File

@ -11,6 +11,7 @@ from django.core.handlers.wsgi import WSGIRequest, get_script_name
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.urls import set_script_prefix from django.urls import set_script_prefix
from django.utils.cache import patch_vary_headers from django.utils.cache import patch_vary_headers
from tornado.iostream import StreamClosedError
from tornado.wsgi import WSGIContainer from tornado.wsgi import WSGIContainer
from zerver.lib.response import AsynchronousResponse, json_response from zerver.lib.response import AsynchronousResponse, json_response
@ -146,7 +147,12 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
self.write(response.content) self.write(response.content)
# Close the connection. # Close the connection.
await self.finish() try:
await self.finish()
except StreamClosedError:
# While writing the response, we might realize that the
# user already closed the connection; that is fine.
pass
async def get(self, *args: Any, **kwargs: Any) -> None: async def get(self, *args: Any, **kwargs: Any) -> None:
request = await self.convert_tornado_request_to_django_request() request = await self.convert_tornado_request_to_django_request()