From 9758900bfce7d84908596a044e76802f8343c4ec Mon Sep 17 00:00:00 2001 From: rmorshea Date: Sat, 22 Apr 2023 23:10:17 -0700 Subject: [PATCH] WSGIContainer.environ changed Specifically it changed from a staticmethod to an instance one. This happened in Tornado 6.3. See: https://github.com/tornadoweb/tornado/pull/3231#issuecomment-1518957578 --- src/reactpy/backend/tornado.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/reactpy/backend/tornado.py b/src/reactpy/backend/tornado.py index c2a034ab2..b79f5fa0e 100644 --- a/src/reactpy/backend/tornado.py +++ b/src/reactpy/backend/tornado.py @@ -196,7 +196,7 @@ async def recv() -> Any: ConnectionContext( self._component_constructor(), value=Connection( - scope=WSGIContainer.environ(self.request), + scope=_FAKE_WSGI_CONTAINER.environ(self.request), location=Location( pathname=f"/{path[len(self._url_prefix):]}", search=( @@ -222,3 +222,10 @@ async def on_message(self, message: str | bytes) -> None: def on_close(self) -> None: if not self._dispatch_future.done(): self._dispatch_future.cancel() + + +# The interface for WSGIContainer.environ changed in Tornado version 6.3 from +# a staticmethod to an instance method. Since we're not that concerned with +# the details of the WSGI app itself, we can just use a fake one. +# see: https://github.com/tornadoweb/tornado/pull/3231#issuecomment-1518957578 +_FAKE_WSGI_CONTAINER = WSGIContainer(lambda *a, **kw: iter([]))