/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Vincent Ladeuil
  • Date: 2009-10-08 08:29:47 UTC
  • mto: (4731.2.5 392127-thread-leak)
  • mto: This revision was merged to the branch mainline in revision 5396.
  • Revision ID: v.ladeuil+lp@free.fr-20091008082947-avilzu93drofi82n
Reduce patch for review purposes.

* bzrlib/tests/http_server.py:
(TestingHTTPServerMixin.connect_socket): Fix python-2.4 missing
feature more simply.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1952
1952
    if use_cache:
1953
1953
        _cached_concurrency = concurrency
1954
1954
    return concurrency
1955
 
 
1956
 
if sys.version_info < (2, 6):
1957
 
    def connect_socket(address):
1958
 
        import socket
1959
 
        """Connect to *address* and return the socket object.
1960
 
 
1961
 
        Convenience function.  Connect to *address* (a 2-tuple ``(host,
1962
 
        port)``) and return the socket object.
1963
 
 
1964
 
        Heavily inspired from the python 2.6 socket.create_connection()
1965
 
        function.
1966
 
        """
1967
 
 
1968
 
        msg = "getaddrinfo returns an empty list"
1969
 
        host, port = address
1970
 
        for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
1971
 
            af, socktype, proto, canonname, sa = res
1972
 
            sock = None
1973
 
            try:
1974
 
                sock = socket.socket(af, socktype, proto)
1975
 
                sock.connect(sa)
1976
 
                return sock
1977
 
 
1978
 
            except socket.error, msg:
1979
 
                if sock is not None:
1980
 
                    sock.close()
1981
 
 
1982
 
        raise socket.error, msg
1983
 
else:
1984
 
    import socket
1985
 
    connect_socket = socket.create_connection