Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(supervisors): fix occasional assertion failures and hangs #2431

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
22 changes: 16 additions & 6 deletions tests/supervisors/test_multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,25 @@ def test_multiprocess_health_check() -> None:
config = Config(app=app, workers=2)
supervisor = Multiprocess(config, target=run, sockets=[])
threading.Thread(target=supervisor.run, daemon=True).start()
# Ensure server is up.
time.sleep(1)
process = supervisor.processes[0]
process.kill()
assert not process.is_alive()
time.sleep(1)
for p in supervisor.processes:
assert p.is_alive()
supervisor.signal_queue.append(signal.SIGINT)
supervisor.join_all()
process.join()
try:
assert not process.is_alive(0.5)
while retry := 3:
try:
for p in supervisor.processes:
assert p.is_alive()
except AssertionError:
retry -= 1
time.sleep(0.5)
else:
break
finally:
supervisor.signal_queue.append(signal.SIGINT)
supervisor.join_all()


@new_console_in_windows
Expand Down
Loading