Compare commits
2 Commits
main
...
stabilize-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1b6fa48f7 | ||
|
|
c22ed477eb |
@ -84,7 +84,11 @@ def test_multiprocess_health_check() -> None:
|
||||
process = supervisor.processes[0]
|
||||
process.kill()
|
||||
assert not process.is_alive()
|
||||
time.sleep(1)
|
||||
deadline = time.monotonic() + 10
|
||||
while time.monotonic() < deadline:
|
||||
if all(p.is_alive() for p in supervisor.processes):
|
||||
break
|
||||
time.sleep(0.1)
|
||||
for p in supervisor.processes:
|
||||
assert p.is_alive()
|
||||
supervisor.signal_queue.append(signal.SIGINT)
|
||||
@ -129,7 +133,13 @@ def test_multiprocess_sighup() -> None:
|
||||
time.sleep(1)
|
||||
pids = [p.pid for p in supervisor.processes]
|
||||
supervisor.signal_queue.append(signal.SIGHUP)
|
||||
time.sleep(1)
|
||||
# Poll instead of a fixed sleep — the supervisor loop runs on a 0.5s interval and `restart_all()` terminates/joins
|
||||
# each worker sequentially, so the total time is non-deterministic.
|
||||
deadline = time.monotonic() + 10
|
||||
while time.monotonic() < deadline:
|
||||
if [p.pid for p in supervisor.processes] != pids:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
assert pids != [p.pid for p in supervisor.processes]
|
||||
supervisor.signal_queue.append(signal.SIGINT)
|
||||
supervisor.join_all()
|
||||
|
||||
@ -16,7 +16,8 @@ from uvicorn import Config, Server
|
||||
async def run_server(config: Config, sockets: list[socket] | None = None) -> AsyncIterator[Server]:
|
||||
server = Server(config=config)
|
||||
task = asyncio.create_task(server.serve(sockets=sockets))
|
||||
await asyncio.sleep(0.1)
|
||||
while not server.started:
|
||||
await asyncio.sleep(0.05)
|
||||
try:
|
||||
yield server
|
||||
finally:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user