File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
tests/unittest/disaggregated Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 11import os
22import signal
3+ import socket
34import subprocess
45import time
56import unittest
910from tensorrt_llm .serve .metadata_server import EtcdDictionary
1011
1112
13+ def wait_for_port (host , port , timeout = 15 ):
14+ start = time .time ()
15+ while time .time () - start < timeout :
16+ try :
17+ with socket .create_connection ((host , port ), timeout = 1 ):
18+ return True
19+ except OSError :
20+ time .sleep (0.5 )
21+ raise RuntimeError (f"Timeout waiting for { host } :{ port } " )
22+
23+
1224def start_etcd_server ():
1325 # Command to start etcd
1426 etcd_cmd = ["etcd" ]
@@ -21,7 +33,6 @@ def start_etcd_server():
2133 preexec_fn = os .setsid ) # This makes it run in a new process group
2234
2335 # Wait a bit for etcd to start
24- time .sleep (5 )
2536
2637 return process
2738
@@ -45,6 +56,8 @@ def setUp(self):
4556 self .host = "localhost"
4657 self .port = 2379
4758
59+ wait_for_port (self .host , self .port )
60+
4861 # Create a clean etcd client for test setup/teardown
4962 self .cleanup_client = etcd3 .client (host = self .host , port = self .port )
5063
You can’t perform that action at this time.
0 commit comments