From: Marcel van der Veldt Date: Fri, 17 Jun 2022 11:43:50 +0000 (+0200) Subject: Fix for port already in use check (#373) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=7ec63c699b704e5dc9261a4dc43406031da4ce0f;p=music-assistant-server.git Fix for port already in use check (#373) --- 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: