Skip to content

Commit cb93902

Browse files
committed
Remove timeout mixins for pre Python 2.6 versions
1 parent f539be6 commit cb93902

File tree

1 file changed

+0
-48
lines changed

1 file changed

+0
-48
lines changed

couchdb/http.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,54 +42,6 @@
4242
__docformat__ = 'restructuredtext en'
4343

4444

45-
if sys.version < '2.6':
46-
47-
class TimeoutMixin:
48-
"""Helper mixin to add timeout before socket connection"""
49-
50-
# taken from original python2.5 httplib source code with timeout setting added
51-
def connect(self):
52-
"""Connect to the host and port specified in __init__."""
53-
msg = "getaddrinfo returns an empty list"
54-
for res in socket.getaddrinfo(self.host, self.port, 0,
55-
socket.SOCK_STREAM):
56-
af, socktype, proto, canonname, sa = res
57-
try:
58-
self.sock = socket.socket(af, socktype, proto)
59-
if self.debuglevel > 0:
60-
print("connect: (%s, %s)" % (self.host, self.port))
61-
62-
# setting socket timeout
63-
self.sock.settimeout(self.timeout)
64-
65-
self.sock.connect(sa)
66-
except socket.error as msg:
67-
if self.debuglevel > 0:
68-
print('connect fail:', self.host, self.port)
69-
if self.sock:
70-
self.sock.close()
71-
self.sock = None
72-
continue
73-
break
74-
if not self.sock:
75-
raise socket.error(msg)
76-
77-
_HTTPConnection = HTTPConnection
78-
_HTTPSConnection = HTTPSConnection
79-
80-
class HTTPConnection(TimeoutMixin, _HTTPConnection):
81-
def __init__(self, *a, **k):
82-
timeout = k.pop('timeout', None)
83-
_HTTPConnection.__init__(self, *a, **k)
84-
self.timeout = timeout
85-
86-
class HTTPSConnection(TimeoutMixin, _HTTPSConnection):
87-
def __init__(self, *a, **k):
88-
timeout = k.pop('timeout', None)
89-
_HTTPSConnection.__init__(self, *a, **k)
90-
self.timeout = timeout
91-
92-
9345
if sys.version < '2.7':
9446

9547
from httplib import CannotSendHeader, _CS_REQ_STARTED, _CS_REQ_SENT

0 commit comments

Comments
 (0)