From 4f5df6d2baf74ac2b2ee9a8500125a420f5c3293 Mon Sep 17 00:00:00 2001 From: kaliko Date: Mon, 4 Mar 2024 16:31:27 +0100 Subject: [PATCH] Add unix socket (closes #1) --- mpdaio/connection.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mpdaio/connection.py b/mpdaio/connection.py index 5da292c..c47cd7e 100644 --- a/mpdaio/connection.py +++ b/mpdaio/connection.py @@ -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() -- 2.39.5