Skip to content

Commit

Permalink
修复压测工具中判断端口是否被占用时可能不生效的问题 (#677)
Browse files Browse the repository at this point in the history
Co-authored-by: liuxu02 <[email protected]>
  • Loading branch information
sujubaima and liuxu02 authored Jul 18, 2024
1 parent f4928bf commit d7b2d93
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/qianfan/dataset/stress_test/yame/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ def is_port_in_use(host: str, port: int) -> bool:
判断port是否被占用
"""
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
return s.connect_ex((host, port)) == 0
try:
s.bind((host, port))
s.close()
return False
except OSError:
return True


def select_a_free_port(
Expand Down

0 comments on commit d7b2d93

Please sign in to comment.