~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Parth Malwankar
  • Date: 2010-07-14 08:53:58 UTC
  • mto: (5050.3.7 2.2)
  • mto: This revision was merged to the branch mainline in revision 5365.
  • Revision ID: parth.malwankar@gmail.com-20100714085358-6un4ny0cn908spkq
better error message for RecursiveBind

Show diffs side-by-side

added added

removed removed

Lines of Context:
2065
2065
            report_activity(sent, 'write')
2066
2066
 
2067
2067
 
2068
 
def connect_socket(address):
2069
 
    # Slight variation of the socket.create_connection() function (provided by
2070
 
    # python-2.6) that can fail if getaddrinfo returns an empty list. We also
2071
 
    # provide it for previous python versions. Also, we don't use the timeout
2072
 
    # parameter (provided by the python implementation) so we don't implement
2073
 
    # it either).
2074
 
    err = socket.error('getaddrinfo returns an empty list')
2075
 
    host, port = address
2076
 
    for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
2077
 
        af, socktype, proto, canonname, sa = res
2078
 
        sock = None
2079
 
        try:
2080
 
            sock = socket.socket(af, socktype, proto)
2081
 
            sock.connect(sa)
2082
 
            return sock
2083
 
 
2084
 
        except socket.error, err:
2085
 
            # 'err' is now the most recent error
2086
 
            if sock is not None:
2087
 
                sock.close()
2088
 
    raise err
2089
 
 
2090
 
 
2091
2068
def dereference_path(path):
2092
2069
    """Determine the real path to a file.
2093
2070