(self)
| 381 | ) |
| 382 | |
| 383 | def _wait_frontend(self): |
| 384 | if self.frontend_process is None or self.frontend_process.stdout is None: |
| 385 | msg = "Frontend process has no stdout." |
| 386 | raise RuntimeError(msg) |
| 387 | while self.frontend_url is None: |
| 388 | line = self.frontend_process.stdout.readline() |
| 389 | if not line: |
| 390 | break |
| 391 | print(line) # for pytest diagnosis #noqa: T201 |
| 392 | m = re.search(reflex.constants.ReactRouter.FRONTEND_LISTENING_REGEX, line) |
| 393 | if m is not None: |
| 394 | self.frontend_url = m.group(1) |
| 395 | config = get_config() |
| 396 | config.deploy_url = self.frontend_url |
| 397 | break |
| 398 | if self.frontend_url is None: |
| 399 | msg = "Frontend did not start" |
| 400 | raise RuntimeError(msg) |
| 401 | |
| 402 | def consume_frontend_output(): |
| 403 | while True: |
| 404 | try: |
| 405 | line = ( |
| 406 | self.frontend_process.stdout.readline() # pyright: ignore [reportOptionalMemberAccess] |
| 407 | ) |
| 408 | # catch I/O operation on closed file. |
| 409 | except ValueError as e: |
| 410 | console.error(str(e)) |
| 411 | break |
| 412 | if not line: |
| 413 | break |
| 414 | |
| 415 | self.frontend_output_thread = threading.Thread(target=consume_frontend_output) |
| 416 | self.frontend_output_thread.start() |
| 417 | |
| 418 | def start(self) -> Self: |
| 419 | """Start the backend in a new thread and dev frontend as a separate process. |
no test coverage detected