Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
4d2a31ab
Unverified
Commit
4d2a31ab
authored
Jul 16, 2025
by
ishandhanani
Committed by
GitHub
Jul 16, 2025
Browse files
chore: add port reservation to utils (#1980)
parent
1e3e4a0c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
examples/sglang/utils/sgl_utils.py
examples/sglang/utils/sgl_utils.py
+16
-2
No files found.
examples/sglang/utils/sgl_utils.py
View file @
4d2a31ab
...
@@ -14,12 +14,12 @@
...
@@ -14,12 +14,12 @@
# limitations under the License.
# limitations under the License.
import
argparse
import
argparse
import
contextlib
import
socket
from
argparse
import
Namespace
from
argparse
import
Namespace
from
sglang.srt.server_args
import
ServerArgs
from
sglang.srt.server_args
import
ServerArgs
from
dynamo.sdk.cli.utils
import
reserve_free_port
def
parse_sglang_args_inc
(
args
:
list
[
str
])
->
ServerArgs
:
def
parse_sglang_args_inc
(
args
:
list
[
str
])
->
ServerArgs
:
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
...
@@ -33,6 +33,20 @@ def parse_sglang_args_inc(args: list[str]) -> ServerArgs:
...
@@ -33,6 +33,20 @@ def parse_sglang_args_inc(args: list[str]) -> ServerArgs:
return
ServerArgs
.
from_cli_args
(
parsed_args
)
return
ServerArgs
.
from_cli_args
(
parsed_args
)
@
contextlib
.
contextmanager
def
reserve_free_port
(
host
:
str
=
"localhost"
):
"""
Find and reserve a free port until context exits.
"""
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
try
:
sock
.
bind
((
host
,
0
))
_
,
port
=
sock
.
getsockname
()
yield
port
finally
:
sock
.
close
()
def
_reserve_disaggregation_bootstrap_port
():
def
_reserve_disaggregation_bootstrap_port
():
"""
"""
Each worker requires a unique port for disaggregation_bootstrap_port.
Each worker requires a unique port for disaggregation_bootstrap_port.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment