检查端口是否被占用
(port)
| 42 | |
| 43 | |
| 44 | def is_port_in_use(port): |
| 45 | """检查端口是否被占用""" |
| 46 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: |
| 47 | return s.connect_ex(("localhost", port)) == 0 |
| 48 | |
| 49 | |
| 50 | def get_available_port(env_key: str, default_start: int): |
no test coverage detected