summaryrefslogtreecommitdiff
path: root/glanceclient/common/utils.py
diff options
context:
space:
mode:
authorStuart McLaren <stuart.mclaren@hp.com>2013-03-20 18:00:39 +0000
committerStuart McLaren <stuart.mclaren@hp.com>2013-04-23 13:48:10 +0000
commit2f33f5f283d921ce1db595a89c36eefb8b8fcd29 (patch)
tree087cd944bc63dc5767f9062d534655365b076429 /glanceclient/common/utils.py
parent42757e8a3cea2cdad3f44c6901ed50586455d81e (diff)
downloadpython-glanceclient-2f33f5f283d921ce1db595a89c36eefb8b8fcd29.tar.gz
Prevent WantReadError when using https
If the glance client is instantiated when the socket module has been monkey patched requests to the server can yield a WantReadError because the socket has been set to non-blocking but this is not being handled correctly. When this is the case use eventlet's GreenConnection which handles non-blocking sockets correctly. Also, for now, add a required getsockopt method to GreenConnection. This can be removed once the eventlet fix (https://bitbucket.org/eventlet/eventlet/commits/609f230) lands. Fixes bug 1157864. Change-Id: I187b69f75b8bcfe16facd41e69b1cd0490dae605
Diffstat (limited to 'glanceclient/common/utils.py')
-rw-r--r--glanceclient/common/utils.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py
index 08e047b..30dcd58 100644
--- a/glanceclient/common/utils.py
+++ b/glanceclient/common/utils.py
@@ -263,3 +263,14 @@ def ensure_str(text, incoming=None,
return text.encode(encoding, errors)
return text
+
+
+def getsockopt(self, *args, **kwargs):
+ """
+ A function which allows us to monkey patch eventlet's
+ GreenSocket, adding a required 'getsockopt' method.
+ TODO: (mclaren) we can remove this once the eventlet fix
+ (https://bitbucket.org/eventlet/eventlet/commits/609f230)
+ lands in mainstream packages.
+ """
+ return self.fd.getsockopt(*args, **kwargs)