🐛 Fix connections being closed too early

Turned UploadStorageFallbackHandler async for this as well.
This commit is contained in:
Gina Häußge committed 2023-11-24 17:34:31 +01:00
1 parent 10c4e6fe89
commit c9bb0eca29
2 files changed
+9 -7

No files matched your search

+3 -1
View File
@@ -1026,7 +1026,9 @@ class Server:
{
"fallback": util.tornado.WsgiInputContainer(
app.wsgi_app,
executor=ThreadPoolExecutor(),
executor=ThreadPoolExecutor(
thread_name_prefix="WsgiRequestHandler"
),
headers=headers,
removed_headers=removed_headers,
),
+6 -6
View File
@@ -564,7 +564,7 @@ class UploadStorageFallbackHandler(RequestlessExceptionLoggingMixin, CorsSupport
self._new_body += value + b"\r\n"
self._new_body += b"--%s--\r\n" % self._multipart_boundary
def _handle_method(self, *args, **kwargs):
async def _handle_method(self, *args, **kwargs):
"""
Takes care of defining the new request body if necessary and forwarding
the current request and changed body to the ``fallback``.
@@ -588,11 +588,11 @@ class UploadStorageFallbackHandler(RequestlessExceptionLoggingMixin, CorsSupport
try:
# call the configured fallback with request and body to use
future = self._fallback(self.request, body)
if future is not None and isinstance(future, tornado.concurrent.Future):
future.add_done_callback(self._cleanup_files)
self._headers_written = True
except Exception:
result = self._fallback(self.request, body)
if result is not None:
await result
# self._headers_written = True
finally:
# make sure the temporary files are removed again
self._cleanup_files()