[Utils] Move network/socket utilities from common.py to network.py - #20646
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the utility codebase by consolidating all network-related functions into a new, dedicated Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the codebase by moving network-related utility functions from common.py to a dedicated network.py file. This is a good step towards better code organization. I've identified a critical bug in the wait_port_available function that could lead to an AttributeError or UnboundLocalError, and I've provided a suggestion to fix it.
network.pycommon.py to network.py
….py to network.py (sgl-project#20646) Resolved conflicts by accepting upstream's network import restructuring in all files. New file: python/sglang/srt/utils/network.py Restored: encode_grpc_server.py, elastic_ep files (deleted in HEAD, updated in upstream). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This change is breaking many UTs as get_Zmq_socket moved to network but did not added in 'python/sglang/srt/utils/init.py'. Causing get_zmq_socket not found. Can you pls handle 'init.py' as well accordingly. |
is_port_available was moved from common.py to network.py in sgl-project#20646 but the package-level re-export was not preserved. This breaks sglang-router 0.3.2 launch_server and any other downstream consumer that imports `from sglang.srt.utils import is_port_available`. Fixes sgl-project#23535
Summary
common.pytonetwork.py:try_bind_socket,is_port_available,get_free_port,bind_port,get_open_port,wait_port_available,find_process_using_port,get_local_ip_auto,get_local_ip_by_nic,get_local_ip_by_remote,is_valid_ipv6_address,_get_addrinfos_for_bindget_zmq_socket,get_zmq_socket_on_host,config_socketsglang.srt.utils.networkcommon.py— clean separation between network and non-network utilitiesFollows up on #20643.