From: Ben Darnell Date: Thu, 9 Feb 2023 21:02:44 +0000 (+0000) Subject: wsgi: Fix formatting X-Git-Tag: v6.3.0b1~9^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=059da0cb105e86b9678d0a1081194584db866246;p=thirdparty%2Ftornado.git wsgi: Fix formatting --- diff --git a/tornado/wsgi.py b/tornado/wsgi.py index b5fb272a5..66d4ca6d5 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -27,16 +27,15 @@ container. """ -import sys -from concurrent import futures +import concurrent.futures from io import BytesIO import tornado +import sys -from tornado import concurrent +from tornado.concurrent import dummy_executor from tornado import escape -from tornado import gen from tornado import httputil -from tornado import ioloop +from tornado.ioloop import IOLoop from tornado.log import access_log from typing import List, Tuple, Optional, Callable, Any, Dict, Text @@ -115,12 +114,18 @@ class WSGIContainer(object): or ``uwsgi``. """ - def __init__(self, wsgi_application: "WSGIAppType", executor: futures.Executor = None) -> None: + def __init__( + self, + wsgi_application: "WSGIAppType", + executor: concurrent.futures.Executor = None, + ) -> None: self.wsgi_application = wsgi_application - self.executor = concurrent.dummy_executor if executor is None else executor + self.executor = dummy_executor if executor is None else executor - @gen.coroutine def __call__(self, request: httputil.HTTPServerRequest) -> None: + IOLoop.current().spawn_callback(self.handle_request, request) + + async def handle_request(self, request: httputil.HTTPServerRequest) -> None: data = {} # type: Dict[str, Any] response = [] # type: List[bytes] @@ -139,8 +144,8 @@ class WSGIContainer(object): data["headers"] = headers return response.append - loop = ioloop.IOLoop.current() - app_response = yield loop.run_in_executor( + loop = IOLoop.current() + app_response = await loop.run_in_executor( self.executor, self.wsgi_application, self.environ(request),