fix: improve CI stability (#900)

This commit is contained in:
suxb201 2024-12-11 17:26:01 +08:00 committed by GitHub
parent 71820fd2ff
commit 770fe60731
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 5 deletions

View File

@ -1,4 +1,3 @@
import random
import socket
import threading
@ -6,17 +5,16 @@ import threading
def is_port_available(port: int) -> bool:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
try:
s.bind(('localhost', port))
s.close()
s.bind(('0.0.0.0', port))
return True
except OSError:
return False
MIN_PORT = 20000
MIN_PORT = 1000
MAX_PORT = 40000
port_cursor = random.choice(range(MIN_PORT, MAX_PORT, 1000))
port_cursor = MIN_PORT
g_lock = threading.Lock()