Fix for port already in use check (#373)
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Fri, 17 Jun 2022 11:43:50 +0000 (13:43 +0200)
committerGitHub <noreply@github.com>
Fri, 17 Jun 2022 11:43:50 +0000 (13:43 +0200)
music_assistant/helpers/util.py

index e190432f216433cae439a717e3d46fc4a7d15f31..e76bb82e9eb2076bb39fc36fc132b57cdeeda493 100755 (executable)
@@ -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: