From 026258c7e82dce1f7aaff7491ae0cb5f08584cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20=C5=9Aliwi=C5=84ski?= Date: Thu, 6 May 2021 18:48:31 +0200 Subject: [PATCH] Windows 10 already has support for AF_UNIX, simulate the flag :hmmm: --- src/mirakuru/unixsocket.py | 3 ++- tests/unixsocketserver_for_tests.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mirakuru/unixsocket.py b/src/mirakuru/unixsocket.py index 3dd1f9ff..f258962a 100644 --- a/src/mirakuru/unixsocket.py +++ b/src/mirakuru/unixsocket.py @@ -24,6 +24,7 @@ LOG = logging.getLogger(__name__) +AF_UNIX = getattr(socket, "AF_UNIX", 1) class UnixSocketExecutor(Executor): """ @@ -65,7 +66,7 @@ def pre_start_check(self) -> bool: Process will be considered started, when it'll be able to accept Unix Socket connections as defined in initializer. """ - exec_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + exec_sock = socket.socket(AF_UNIX, socket.SOCK_STREAM) try: exec_sock.connect(self.socket) return True diff --git a/tests/unixsocketserver_for_tests.py b/tests/unixsocketserver_for_tests.py index fee73f23..95e62f29 100644 --- a/tests/unixsocketserver_for_tests.py +++ b/tests/unixsocketserver_for_tests.py @@ -27,6 +27,8 @@ import os from time import sleep +from mirakuru.unixsocket import AF_UNIX + SOCKET_ADDRESS = "./uds_socket" SLEEP = 0 @@ -45,7 +47,7 @@ raise # Create a UDS socket -SOCK = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +SOCK = socket.socket(AF_UNIX, socket.SOCK_STREAM) # Bind the socket to the address print(f"starting up on {SOCKET_ADDRESS}")