File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 33from __future__ import annotations
44
55import asyncio
6+ import concurrent .futures
67import traceback
78from collections .abc import Mapping , Sequence
89from datetime import datetime
@@ -195,12 +196,15 @@ def compile_state(state: type[BaseState]) -> dict:
195196 """
196197 initial_state = state (_reflex_internal_init = True ).dict (initial = True )
197198 try :
198- loop = asyncio .get_running_loop ()
199+ _ = asyncio .get_running_loop ()
199200 except RuntimeError :
200201 pass
201202 else :
202- future = asyncio .run_coroutine_threadsafe (_resolve_delta (initial_state ), loop )
203- return _sorted_keys (future .result ())
203+ with concurrent .futures .ThreadPoolExecutor () as pool :
204+ resolved_initial_state = pool .submit (
205+ asyncio .run , _resolve_delta (initial_state )
206+ ).result ()
207+ return _sorted_keys (resolved_initial_state )
204208
205209 # Normally the compile runs before any event loop starts, we asyncio.run is available for calling.
206210 return _sorted_keys (asyncio .run (_resolve_delta (initial_state )))
You can’t perform that action at this time.
0 commit comments