Skip to content

[Bug] port is not an integer in function get_open_port() #4527

@Jakeuibn

Description

@Jakeuibn

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
  • 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/sgl-project/sglang/discussions/new/choose Otherwise, it will be closed.
  • 5. Please use English, otherwise it will be closed.

Describe the bug

in function get_open_port,port is a string, so s.bind(("", port)) will have TypeError: an integer is required (got type str)
to fix it, simple add port=int(port) here

def get_open_port() -> int:
    port = os.getenv("SGLANG_PORT")
    if port is not None:
        # port=int(port)  # add here
        while True:
            try:
                with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
                    s.bind(("", port))
                    return port
            except OSError:
                port += 1  # Increment port number if already in use
                logger.info("Port %d is already in use, trying port %d", port - 1, port)
    ...

Reproduction

from sglang.srt.distributed.device_communicators.shm_broadcast import MessageQueue
queue=MessageQueue(n_reader=1, n_local_reader=1) 

Environment

my python version is 3.9
my environment is not correct, but it is not necessary in the bug

python3 -m sglang.check_env

UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation. 
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
  warnings.warn(

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions