[Utils] Move network/socket utilities from common.py to network.py (#20646)
This commit is contained in:
@@ -12,7 +12,8 @@ import zmq
|
||||
from sglang import Engine
|
||||
from sglang.srt.observability.trace import *
|
||||
from sglang.srt.observability.trace import get_cur_time_ns, set_global_trace_level
|
||||
from sglang.srt.utils import get_zmq_socket, kill_process_tree
|
||||
from sglang.srt.utils import kill_process_tree
|
||||
from sglang.srt.utils.network import get_zmq_socket
|
||||
from sglang.test.test_utils import (
|
||||
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
|
||||
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
|
||||
|
||||
@@ -8,7 +8,8 @@ import grpc
|
||||
import zmq
|
||||
from grpc_health.v1 import health_pb2, health_pb2_grpc
|
||||
|
||||
from sglang.srt.utils import get_zmq_socket_on_host, kill_process_tree
|
||||
from sglang.srt.utils import kill_process_tree
|
||||
from sglang.srt.utils.network import get_zmq_socket_on_host
|
||||
from sglang.test.ci.ci_register import register_cuda_ci
|
||||
from sglang.test.kits.mmmu_vlm_kit import _run_lmms_eval_with_retry
|
||||
from sglang.test.server_fixtures.disaggregation_fixture import (
|
||||
|
||||
@@ -3,7 +3,7 @@ import socket
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from sglang.srt.utils.common import (
|
||||
from sglang.srt.utils.network import (
|
||||
_get_addrinfos_for_bind,
|
||||
bind_port,
|
||||
get_free_port,
|
||||
@@ -78,7 +78,7 @@ class TestTryBindSocket(CustomTestCase):
|
||||
def test_gaierror_fallback(self):
|
||||
"""_get_addrinfos_for_bind should fall back to AF_INET on gaierror."""
|
||||
with patch(
|
||||
"sglang.srt.utils.common.socket.getaddrinfo",
|
||||
"sglang.srt.utils.network.socket.getaddrinfo",
|
||||
side_effect=socket.gaierror("mocked"),
|
||||
):
|
||||
infos = _get_addrinfos_for_bind()
|
||||
@@ -90,7 +90,7 @@ class TestTryBindSocket(CustomTestCase):
|
||||
def test_gaierror_fallback_preserves_host(self):
|
||||
"""Fallback should use the provided host, not default to 0.0.0.0."""
|
||||
with patch(
|
||||
"sglang.srt.utils.common.socket.getaddrinfo",
|
||||
"sglang.srt.utils.network.socket.getaddrinfo",
|
||||
side_effect=socket.gaierror("mocked"),
|
||||
):
|
||||
infos = _get_addrinfos_for_bind(host="10.0.0.1", port=8080)
|
||||
@@ -187,7 +187,7 @@ class TestReservePort(CustomTestCase):
|
||||
def test_reserve_port_no_free_port_raises(self):
|
||||
"""reserve_port should raise RuntimeError if no port is available."""
|
||||
with patch(
|
||||
"sglang.srt.utils.common.try_bind_socket",
|
||||
"sglang.srt.utils.network.try_bind_socket",
|
||||
side_effect=OSError("mocked"),
|
||||
):
|
||||
with self.assertRaises(RuntimeError):
|
||||
|
||||
Reference in New Issue
Block a user