Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tornado: Ignore StreamClosedError.

Anders Kaseorg4fc3845dc253
diff --git a/zerver/tornado/handlers.py b/zerver/tornado/handlers.py
index 194b912794a..5a94daec10a 100644
--- a/zerver/tornado/handlers.py
+++ b/zerver/tornado/handlers.py
@@ -11,6 +11,7 @@ from django.core.handlers.wsgi import WSGIRequest, get_script_name
from django.http import HttpRequest, HttpResponse
from django.urls import set_script_prefix
from django.utils.cache import patch_vary_headers
+from tornado.iostream import StreamClosedError
from tornado.wsgi import WSGIContainer
from zerver.lib.response import AsynchronousResponse, json_response
@@ -146,7 +147,12 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
self.write(response.content)
# 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:
request = await self.convert_tornado_request_to_django_request()