Skip to content

Commit 7be490b

Browse files
committed
fix: workaround for macOS AF_UNIX path error
@pytest.mark.openchannel('v1') @pytest.mark.openchannel('v2') def test_pay(node_factory): > l1, l2 = node_factory.line_graph(2) ... FAILED tests/test_pay.py::test_pay - OSError: AF_UNIX path too lon Changelog-None: symlink the socket to a tempfile which has a shorter path Signed-off-by: Lakshya Singh <[email protected]>
1 parent 90b5f04 commit 7be490b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: contrib/pyln-client/pyln/client/lightning.py

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import socket
55
import sys
6+
import tempfile
67
from contextlib import contextmanager
78
from decimal import Decimal
89
from json import JSONEncoder
@@ -256,6 +257,14 @@ def connect(self) -> None:
256257
short_path = "/proc/self/fd/%d/%s" % (dirfd, basename)
257258
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
258259
self.sock.connect(short_path)
260+
elif (e.args[0] == "AF_UNIX path too long" and os.uname()[0] == "Darwin"):
261+
temp_dir = tempfile.mkdtemp()
262+
temp_link = os.path.join(temp_dir, "socket_link")
263+
if os.path.exists(temp_link):
264+
os.unlink(temp_link)
265+
os.symlink(self.path, temp_link)
266+
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
267+
self.sock.connect(temp_link)
259268
else:
260269
# There is no good way to recover from this.
261270
raise

0 commit comments

Comments
 (0)