|
23 | 23 | from reflex.istate.storage import Cookie, LocalStorage, SessionStorage |
24 | 24 | from reflex.state import BaseState, _resolve_delta |
25 | 25 | from reflex.style import Style |
26 | | -from reflex.utils import console, format, imports, path_ops |
27 | | -from reflex.utils.exec import is_in_app_harness |
| 26 | +from reflex.utils import format, imports, path_ops |
28 | 27 | from reflex.utils.imports import ImportVar, ParsedImportDict |
29 | 28 | from reflex.utils.prerequisites import get_web_dir |
30 | 29 | from reflex.vars.base import Field, Var |
@@ -201,16 +200,11 @@ def compile_state(state: type[BaseState]) -> dict: |
201 | 200 | except RuntimeError: |
202 | 201 | pass |
203 | 202 | else: |
204 | | - if is_in_app_harness(): |
205 | | - # Playwright tests already have an event loop running, so we can't use asyncio.run. |
206 | | - with concurrent.futures.ThreadPoolExecutor() as pool: |
207 | | - resolved_initial_state = pool.submit( |
208 | | - asyncio.run, _resolve_delta(initial_state) |
209 | | - ).result() |
210 | | - console.warn( |
211 | | - f"Had to get initial state in a thread 🤮 {resolved_initial_state}", |
212 | | - ) |
213 | | - return _sorted_keys(resolved_initial_state) |
| 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) |
214 | 208 |
|
215 | 209 | # Normally the compile runs before any event loop starts, we asyncio.run is available for calling. |
216 | 210 | return _sorted_keys(asyncio.run(_resolve_delta(initial_state))) |
|
0 commit comments