Skip to content

Commit 32b367c

Browse files
committed
Merge branch 'asgi-middleware' of https://github.com/Archmonger/reactpy into asgi-middleware
2 parents 473cdfd + b350590 commit 32b367c

File tree

1 file changed

+5
-7
lines changed
  • src/py/reactpy/reactpy/backend

1 file changed

+5
-7
lines changed

src/py/reactpy/reactpy/backend/asgi.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def __init__(
7878
self._cached_index_html = ""
7979
self.connected = False
8080
self.backhaul_thread = backhaul_thread
81+
self.dispatcher = None
8182
self.block_size = block_size
82-
self.dispatcher_future_or_task = None
8383
if self.backhaul_thread and not _backhaul_thread.is_alive():
8484
_backhaul_thread.start()
8585

@@ -94,8 +94,6 @@ async def __call__(self, scope, receive, send) -> None:
9494
# Serve the user's application
9595
await self.user_app(scope, receive, send)
9696

97-
_logger.error("ReactPy appears to be misconfigured. Request not handled.")
98-
9997
async def reactpy_app(self, scope, receive, send) -> None:
10098
"""Determine what type of request this is and route it to the appropriate
10199
ReactPy ASGI sub-application."""
@@ -139,15 +137,15 @@ async def component_dispatch_app(self, scope, receive, send) -> None:
139137
await send({"type": "websocket.accept"})
140138
run_dispatcher = self.run_dispatcher(scope, receive, send)
141139
if self.backhaul_thread:
142-
self.dispatcher_future_or_task = asyncio.run_coroutine_threadsafe(
140+
self.dispatcher = asyncio.run_coroutine_threadsafe(
143141
run_dispatcher, _backhaul_loop
144142
)
145143
else:
146-
self.dispatcher_future_or_task = asyncio.create_task(run_dispatcher)
144+
self.dispatcher = asyncio.create_task(run_dispatcher)
147145

148146
if event["type"] == "websocket.disconnect":
149-
if self.dispatcher_future_or_task:
150-
self.dispatcher_future_or_task.cancel()
147+
if self.dispatcher:
148+
self.dispatcher.cancel()
151149
break
152150

153151
if event["type"] == "websocket.receive":

0 commit comments

Comments
 (0)