]> kaliko git repositories - python-musicpdaio.git/commitdiff
Add unix socket (closes #1)
authorkaliko <kaliko@azylum.org>
Mon, 4 Mar 2024 15:31:27 +0000 (16:31 +0100)
committerkaliko <kaliko@azylum.org>
Mon, 4 Mar 2024 15:31:27 +0000 (16:31 +0100)
mpdaio/connection.py

index 5da292c0eae5a209cacd598537e852eb8397c954..c47cd7ea3f52705d49ca50f6ba40b0442278f1e9 100644 (file)
@@ -61,12 +61,18 @@ class ConnectionPool(base):
                     if not conn.in_use:
                         await conn.close()
                         break
-
-            log.debug('about to connect %s', host)
-            reader, writer = await asyncio.wait_for(
-                    asyncio.open_connection(server, port),
-                    timeout
-                    )
+            if server[0] in ['/', '@']:
+                log.debug('about to connect unix socket %s', server)
+                reader, writer = await asyncio.wait_for(
+                        asyncio.open_unix_connection(path=server),
+                        timeout
+                        )
+            else:
+                log.debug('about to connect tcp socket %s:%s', *host)
+                reader, writer = await asyncio.wait_for(
+                        asyncio.open_connection(server, port),
+                        timeout
+                        )
             #log.debug('Connected to %s:%s', host[0], host[1])
             connection = Connection(self, host, reader, writer)
             await connection._hello()