MCPcopy Index your code
hub / github.com/reactive-python/reactpy / run_dispatcher

Function run_dispatcher

src/py/reactpy/reactpy/backend/flask.py:218–258  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216
217 @copy_current_request_context
218 def run_dispatcher() -> None:
219 loop = asyncio.new_event_loop()
220 asyncio.set_event_loop(loop)
221
222 thread_send_queue: ThreadQueue[Any] = ThreadQueue()
223 async_recv_queue: AsyncQueue[Any] = AsyncQueue()
224
225 async def send_coro(value: Any) -> None:
226 thread_send_queue.put(value)
227
228 async def main() -> None:
229 search = request.query_string.decode()
230 await serve_layout(
231 reactpy.Layout(
232 ConnectionContext(
233 component,
234 value=Connection(
235 scope=request.environ,
236 location=Location(
237 pathname=f"/{path}",
238 search=f"?{search}" if search else "",
239 ),
240 carrier=_FlaskCarrier(request, websocket),
241 ),
242 ),
243 ),
244 send_coro,
245 async_recv_queue.get,
246 )
247
248 main_future = asyncio.ensure_future(main(), loop=loop)
249
250 dispatch_thread_info_ref.current = _DispatcherThreadInfo(
251 dispatch_loop=loop,
252 dispatch_future=main_future,
253 thread_send_queue=thread_send_queue,
254 async_recv_queue=async_recv_queue,
255 )
256 dispatch_thread_info_created.set()
257
258 loop.run_until_complete(main_future)
259
260 Thread(target=run_dispatcher, daemon=True).start()
261

Callers

nothing calls this directly

Calls 2

mainFunction · 0.70

Tested by

no test coverage detected