MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / is_port_available

Function is_port_available

fastdeploy/utils.py:622–637  ·  view source on GitHub ↗

Check the port is available

(host, port)

Source from the content-addressed store, hash-verified

620
621
622def is_port_available(host, port):
623 """
624 Check the port is available
625 """
626 import errno
627 import socket
628
629 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
630 try:
631 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
632 s.bind((host, port))
633 return True
634 except OSError as e:
635 if e.errno == errno.EADDRINUSE:
636 return False
637 return True
638
639
640def find_free_ports(

Callers 7

post_init_portsMethod · 0.90
launch_api_serverFunction · 0.90
check_paramFunction · 0.90
launch_api_serverFunction · 0.90
launch_metrics_serverFunction · 0.90
launch_controller_serverFunction · 0.90
find_free_portsFunction · 0.85

Calls 3

socketMethod · 0.80
setsockoptMethod · 0.80
bindMethod · 0.80

Tested by

no test coverage detected