Rev 4735: Reduce patch for review purposes. in file:///home/vila/src/bzr/bugs/405745-http-hangs/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Oct 8 09:29:47 BST 2009
At file:///home/vila/src/bzr/bugs/405745-http-hangs/
------------------------------------------------------------
revno: 4735
revision-id: v.ladeuil+lp at free.fr-20091008082947-avilzu93drofi82n
parent: v.ladeuil+lp at free.fr-20091008080456-gzpvefk1170kxxtb
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 405745-http-hangs
timestamp: Thu 2009-10-08 10:29:47 +0200
message:
Reduce patch for review purposes.
* bzrlib/tests/http_server.py:
(TestingHTTPServerMixin.connect_socket): Fix python-2.4 missing
feature more simply.
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2009-10-08 08:04:56 +0000
+++ b/bzrlib/osutils.py 2009-10-08 08:29:47 +0000
@@ -1952,34 +1952,3 @@
if use_cache:
_cached_concurrency = concurrency
return concurrency
-
-if sys.version_info < (2, 6):
- def connect_socket(address):
- import socket
- """Connect to *address* and return the socket object.
-
- Convenience function. Connect to *address* (a 2-tuple ``(host,
- port)``) and return the socket object.
-
- Heavily inspired from the python 2.6 socket.create_connection()
- function.
- """
-
- msg = "getaddrinfo returns an empty list"
- host, port = address
- for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
- af, socktype, proto, canonname, sa = res
- sock = None
- try:
- sock = socket.socket(af, socktype, proto)
- sock.connect(sa)
- return sock
-
- except socket.error, msg:
- if sock is not None:
- sock.close()
-
- raise socket.error, msg
-else:
- import socket
- connect_socket = socket.create_connection
=== modified file 'bzrlib/tests/http_server.py'
--- a/bzrlib/tests/http_server.py 2009-10-08 08:04:56 +0000
+++ b/bzrlib/tests/http_server.py 2009-10-08 08:29:47 +0000
@@ -30,10 +30,7 @@
import urllib
import urlparse
-from bzrlib import (
- transport,
- osutils,
- )
+from bzrlib import transport
from bzrlib.transport import local
@@ -345,6 +342,21 @@
self.server_close()
self.is_shut_down.set()
+ def connect_socket(self):
+ msg = "getaddrinfo returns an empty list"
+ for res in socket.getaddrinfo(*self.server_address):
+ af, socktype, proto, canonname, sa = res
+ sock = None
+ try:
+ sock = socket.socket(af, socktype, proto)
+ sock.connect(sa)
+ return sock
+
+ except socket.error, msg:
+ if sock is not None:
+ sock.close()
+ raise socket.error, msg
+
def shutdown(self):
"""Stops the serve() loop.
@@ -356,7 +368,7 @@
self.serving = False
# The server is listening for a last connection, let's give it:
try:
- fake_conn = osutils.connect_socket(self.server_address)
+ fake_conn = self.connect_socket()
fake_conn.close()
except socket.error, e:
# But ignore connection errors as the point is to unblock the
More information about the bazaar-commits
mailing list