From 7ec63c699b704e5dc9261a4dc43406031da4ce0f Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 17 Jun 2022 13:43:50 +0200 Subject: [PATCH] Fix for port already in use check (#373) --- music_assistant/helpers/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/music_assistant/helpers/util.py b/music_assistant/helpers/util.py index e190432f..e76bb82e 100755 --- a/music_assistant/helpers/util.py +++ b/music_assistant/helpers/util.py @@ -163,7 +163,10 @@ def get_ip(): def is_port_in_use(port: int) -> bool: """Check if port is in use.""" with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as _sock: - return _sock.connect_ex(("localhost", port)) == 0 + try: + return _sock.connect_ex(("localhost", port)) == 0 + except socket.gaierror: + return True def select_stream_port() -> int: -- 2.34.1