diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index b290ede03..0f8928f5c 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -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, ), diff --git a/src/octoprint/server/util/tornado.py b/src/octoprint/server/util/tornado.py index 96136983a..3ab3bf621 100644 --- a/src/octoprint/server/util/tornado.py +++ b/src/octoprint/server/util/tornado.py @@ -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()