Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/22247#discussion_r213174542
--- Diff: python/pyspark/java_gateway.py ---
@@ -147,6 +147,39 @@ def do_server_auth(conn, auth_secret):
raise Exception("Unexpected reply from iterator server.")
+def local_connect_and_auth(sock_info):
+ """
+ Connect to local host, authenticate with it, and return a
(sockfile,sock) for that connection.
+ Handles IPV4 & IPV6, does some error handling.
+ :param sock_info: a tuple of (port, auth_secret) for connecting
+ :return: a tuple with (sockfile, sock)
+ """
+ port, auth_secret = sock_info
+ sock = None
+ errors = []
+ # Support for both IPv4 and IPv6.
+ # On most of IPv6-ready systems, IPv6 will take precedence.
+ for res in socket.getaddrinfo("127.0.0.1", port, socket.AF_UNSPEC,
socket.SOCK_STREAM):
+ af, socktype, proto, canonname, sa = res
--- End diff --
nit: `af, socktype, proto, canonname, sa = res` -> `af, socktype, proto, _,
sa = res`
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]