Skip to content

Commit 3d66da1

Browse files
authored
ci : gracefully shut down the server (#21110)
Signed-off-by: Adrien Gallouët <angt@huggingface.co>
1 parent 82b703f commit 3d66da1

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

tools/server/tests/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,15 @@ def stop(self) -> None:
288288
server_instances.remove(self)
289289
if self.process:
290290
print(f"Stopping server with pid={self.process.pid}")
291-
self.process.kill()
291+
self.process.terminate()
292+
try:
293+
self.process.wait(timeout=5)
294+
except subprocess.TimeoutExpired:
295+
print(f"Server pid={self.process.pid} did not terminate in time, killing")
296+
self.process.kill()
297+
self.process.wait(timeout=5)
298+
except Exception as e:
299+
print(f"Error waiting for server: {e}")
292300
self.process = None
293301

294302
def make_request(

0 commit comments

Comments
 (0)