~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Jelmer Vernooij
  • Date: 2010-08-20 19:07:17 UTC
  • mfrom: (5385 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5389.
  • Revision ID: jelmer@samba.org-20100820190717-txm7aiyh6wtumgd3
merge bzr.dev.

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