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 21 commits into
base: master
Choose a base branch
from
Open
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions tests/supervisors/test_multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def new_function():
"-c",
f"from {module} import {name}; {name}.__wrapped__()",
],
timeout=10,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this was added earlier when I was investigating why it was hanging. No need for it now, I'll remove it later

creationflags=subprocess.CREATE_NO_WINDOW, # type: ignore[attr-defined]
)

Expand Down Expand Up @@ -83,15 +84,18 @@ 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()
time.sleep(1)
time.sleep(1) # ensure server is up
vvanglro marked this conversation as resolved.
Show resolved Hide resolved
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)
time.sleep(1.5) # release gil, ensure process restart complete.
for p in supervisor.processes:
assert p.is_alive()
finally:
supervisor.signal_queue.append(signal.SIGINT)
supervisor.join_all()


@new_console_in_windows
Expand Down
Loading