Skip to content

Commit 5df567e

Browse files
committed
local ws connection
1 parent 24fb817 commit 5df567e

File tree

1 file changed

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

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,14 @@ async def component_dispatch_app(
152152
send: Callable[..., Coroutine],
153153
) -> None:
154154
"""ASGI app for rendering ReactPy Python components."""
155+
ws_connected: bool = False
156+
155157
while True:
158+
# Future WS events on this connection will always be received here
156159
event = await receive()
157160

158-
if event["type"] == "websocket.connect" and not self.connected:
159-
self.connected = True
161+
if event["type"] == "websocket.connect" and not ws_connected:
162+
ws_connected = True
160163
await send({"type": "websocket.accept"})
161164
run_dispatcher = self.run_dispatcher(scope, receive, send)
162165
if self.backhaul_thread:

0 commit comments

Comments
 (0)