Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6338#discussion_r33014685
  
    --- Diff: python/pyspark/rdd.py ---
    @@ -121,14 +121,21 @@ def _parse_memory(s):
     
     
     def _load_from_socket(port, serializer):
    -    sock = socket.socket()
    -    sock.settimeout(3)
    -    try:
    -        sock.connect(("localhost", port))
    +    sock = None
    +    for res in socket.getaddrinfo("localhost", port, socket.AF_UNSPEC, 
socket.SOCK_STREAM):
    +        af, socktype, proto, canonname, sa = res
    +        try:
    +            sock = socket.socket(af, socktype, proto)
    +            sock.settimeout(3)
    +            sock.connect(sa)
    +        except socket.error:
    +            sock = None
    +            continue
    +        break
    +    if sock:
             rf = sock.makefile("rb", 65536)
             for item in serializer.load_stream(rf):
                 yield item
    -    finally:
    --- End diff --
    
    I think we can do this by just indenting the contents of this `if` branch 
and putting them into a `try-finally`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to