mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-04-21 06:48:56 +00:00
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:
@@ -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
|
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:
|
test_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
return s.connect_ex(("localhost", port)) == 0
|
test_socket.settimeout(1)
|
||||||
|
with test_socket:
|
||||||
|
return test_socket.connect_ex(("localhost", port)) == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user