Network: Fix socket check timeout
Make this a one second timeout to check if a socket is connected. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
1e56d43772
commit
ed7cd3cb59
1 changed files with 4 additions and 2 deletions
|
|
@ -92,5 +92,7 @@ def is_port_in_use(port: int) -> bool:
|
|||
From https://stackoverflow.com/questions/2470971/fast-way-to-test-if-a-port-is-in-use-using-python
|
||||
"""
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
return s.connect_ex(("localhost", port)) == 0
|
||||
test_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
test_socket.settimeout(1)
|
||||
with test_socket:
|
||||
return test_socket.connect_ex(("localhost", port)) == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue