File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1414# limitations under the License.
1515
1616import argparse
17+ import contextlib
18+ import socket
1719from argparse import Namespace
1820
1921from sglang .srt .server_args import ServerArgs
2022
21- from dynamo .sdk .cli .utils import reserve_free_port
22-
2323
2424def parse_sglang_args_inc (args : list [str ]) -> ServerArgs :
2525 parser = argparse .ArgumentParser ()
@@ -33,6 +33,20 @@ def parse_sglang_args_inc(args: list[str]) -> ServerArgs:
3333 return ServerArgs .from_cli_args (parsed_args )
3434
3535
36+ @contextlib .contextmanager
37+ def reserve_free_port (host : str = "localhost" ):
38+ """
39+ Find and reserve a free port until context exits.
40+ """
41+ sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
42+ try :
43+ sock .bind ((host , 0 ))
44+ _ , port = sock .getsockname ()
45+ yield port
46+ finally :
47+ sock .close ()
48+
49+
3650def _reserve_disaggregation_bootstrap_port ():
3751 """
3852 Each worker requires a unique port for disaggregation_bootstrap_port.
You can’t perform that action at this time.
0 commit comments