Skip to content

Commit 5238467

Browse files
authored
test: accept completed fullstack launchers during shutdown (#7501)
1 parent d0e4b34 commit 5238467

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

‎tests/units/test_reflex.py‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -705,20 +705,13 @@ def backend(*args):
705705
)
706706
child = None
707707
try:
708-
deadline = time.monotonic() + DEFAULT_TIMEOUT
709-
while time.monotonic() < deadline:
710-
if launcher.poll() is not None:
711-
pytest.fail(f"launcher exited early: {launcher.returncode}")
712-
if pids.exists() and (pid := pids.read_text().strip()):
713-
child = int(pid)
714-
break
715-
time.sleep(0.01)
716-
assert child is not None
717-
try:
718-
launcher.wait(timeout=2)
719-
except subprocess.TimeoutExpired:
720-
pytest.fail("full-stack run hung after backend returned")
721-
assert launcher.returncode == 0
708+
# The launcher may finish before the parent gets scheduled to observe it.
709+
_, stderr = launcher.communicate(timeout=DEFAULT_TIMEOUT)
710+
assert pids.exists(), (
711+
"frontend did not start: " + stderr.decode(errors="replace")[-1000:]
712+
)
713+
child = int(pids.read_text().strip())
714+
assert launcher.returncode == 0, stderr.decode(errors="replace")[-1000:]
722715
with contextlib.suppress(psutil.NoSuchProcess):
723716
assert psutil.Process(child).status() in (
724717
psutil.STATUS_ZOMBIE,
@@ -727,7 +720,7 @@ def backend(*args):
727720
finally:
728721
if launcher.poll() is None:
729722
os.killpg(launcher.pid, signal.SIGKILL)
730-
launcher.wait(timeout=DEFAULT_TIMEOUT)
723+
launcher.communicate(timeout=DEFAULT_TIMEOUT)
731724
if child is not None:
732725
with contextlib.suppress(ProcessLookupError):
733726
os.kill(child, signal.SIGKILL)

0 commit comments

Comments
 (0)