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: Avoid failing tests on unknown kill_server behavior #102

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def __init__(self, repo=None, mode="local", timeout=60):
self.repo = repo
self.mode = mode
self.timeout = timeout
self.proc = None

def __enter__(self):
self.start()
Expand All @@ -132,6 +133,9 @@ def run_server(self, repo=None, mode="local"):
return p

def wait_for_server_ready(self, timeout: int = 60):
if not self.proc:
raise RuntimeError("Server process wasn't started")

start = time.time()
while True:
try:
Expand All @@ -147,6 +151,12 @@ def wait_for_server_ready(self, timeout: int = 60):
raise RuntimeError("Server failed to start in time.") from err

def kill_server(self, timeout: int = 60):
if not self.proc:
# If process wasn't started by this point, just print the error and
# gracefully exit for now.
print("ERROR: Server process wasn't started")
return

try:
self.proc.terminate()
self.proc.wait(timeout=timeout) # Wait for triton to clean up
Expand All @@ -155,6 +165,8 @@ def kill_server(self, timeout: int = 60):
self.proc.wait() # Indefinetely wait until the process is cleaned up.
except psutil.NoSuchProcess as e:
print(e)
except AttributeError as e:
print(e)

def check_server_ready(self):
status_grpc = TritonCommands._status(protocol="grpc")
Expand Down