Skip to content

Commit

Permalink
Windows 10 already has support for AF_UNIX, simulate the flag :hmmm:
Browse files Browse the repository at this point in the history
  • Loading branch information
fizyk committed May 6, 2021
1 parent a2a486a commit 026258c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/mirakuru/unixsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

LOG = logging.getLogger(__name__)

AF_UNIX = getattr(socket, "AF_UNIX", 1)

class UnixSocketExecutor(Executor):
"""
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/unixsocketserver_for_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import os
from time import sleep

from mirakuru.unixsocket import AF_UNIX

SOCKET_ADDRESS = "./uds_socket"

SLEEP = 0
Expand All @@ -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}")
Expand Down

0 comments on commit 026258c

Please sign in to comment.