summaryrefslogtreecommitdiff
path: root/keystoneclient/session.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-09-08 23:09:42 +0000
committerGerrit Code Review <review@openstack.org>2015-09-08 23:09:42 +0000
commitf630894f66e6048daf299fb2bab2ffeff6666693 (patch)
treedfb8f428bcc7dfaf79ab5d5e511aacbbdd6446ff /keystoneclient/session.py
parent6231459156c7ffcea574efb2e01ce0b5ec78d9ac (diff)
parent33b24a6984c8de2f26af7900202bb85b6b5db125 (diff)
downloadpython-keystoneclient-f630894f66e6048daf299fb2bab2ffeff6666693.tar.gz
Merge "Fixes missing socket attribute error during init_poolmanager"
Diffstat (limited to 'keystoneclient/session.py')
-rw-r--r--keystoneclient/session.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/keystoneclient/session.py b/keystoneclient/session.py
index 6f2e930..e3db3b9 100644
--- a/keystoneclient/session.py
+++ b/keystoneclient/session.py
@@ -938,10 +938,6 @@ class TCPKeepAliveAdapter(requests.adapters.HTTPAdapter):
(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),
# Turn on TCP Keep-Alive
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
- # Set the maximum number of keep-alive probes
- (socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 4),
- # Send keep-alive probes every 15 seconds
- (socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 15),
]
# Some operating systems (e.g., OSX) do not support setting
@@ -952,6 +948,23 @@ class TCPKeepAliveAdapter(requests.adapters.HTTPAdapter):
(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 60)
]
+ # TODO(claudiub): Windows does not contain the TCP_KEEPCNT and
+ # TCP_KEEPINTVL socket attributes. Instead, it contains
+ # SIO_KEEPALIVE_VALS, which can be set via ioctl, which should be
+ # set once it is available in requests.
+ # https://msdn.microsoft.com/en-us/library/dd877220%28VS.85%29.aspx
+ if hasattr(socket, 'TCP_KEEPCNT'):
+ socket_options += [
+ # Set the maximum number of keep-alive probes
+ (socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 4)
+ ]
+
+ if hasattr(socket, 'TCP_KEEPINTVL'):
+ socket_options += [
+ # Send keep-alive probes every 15 seconds
+ (socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 15)
+ ]
+
# After waiting 60 seconds, and then sending a probe once every 15
# seconds 4 times, these options should ensure that a connection
# hands for no longer than 2 minutes before a ConnectionError is