summaryrefslogtreecommitdiff
path: root/keystoneclient/httpclient.py
diff options
context:
space:
mode:
authorJamie Lennox <jamielennox@redhat.com>2014-07-23 09:14:56 +1000
committerJamie Lennox <jamielennox@redhat.com>2014-08-21 05:29:49 +0000
commit8fcacdc7c74f5ac68e8e55ea8c15918c452411fe (patch)
tree6a26d6c50d03b8fb662273cf08628f7fffff092c /keystoneclient/httpclient.py
parentc9ae9d1fa267653c1779a9a17613bd287f1297a3 (diff)
downloadpython-keystoneclient-8fcacdc7c74f5ac68e8e55ea8c15918c452411fe.tar.gz
Move fake session to HTTPClient
The fake session object is to prevent a cyclical dependency between HTTPClient and the session from leaving hanging session objects around. This is still necessary if you construct a client the old way however if you are using the session properly then there is no cyclical dependency and so we shouldn't prevent people using the connection pooling advantages of the session. Related-Bug: #1282089 Change-Id: Ifca2c7ddd95a81af01ee43246ecc8e74abf95602
Diffstat (limited to 'keystoneclient/httpclient.py')
-rw-r--r--keystoneclient/httpclient.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/keystoneclient/httpclient.py b/keystoneclient/httpclient.py
index 48e12b7..cab60bc 100644
--- a/keystoneclient/httpclient.py
+++ b/keystoneclient/httpclient.py
@@ -22,6 +22,7 @@ OpenStack Client interface. Handles the REST calls and responses.
import logging
import pkg_resources
+import requests
from six.moves.urllib import parse as urlparse
try:
@@ -66,6 +67,22 @@ USER_AGENT = client_session.USER_AGENT
request = client_session.request
+class _FakeRequestSession(object):
+ """This object is a temporary hack that should be removed later.
+
+ Keystoneclient has a cyclical dependency with its managers which is
+ preventing it from being cleaned up correctly. This is always bad but when
+ we switched to doing connection pooling this object wasn't getting cleaned
+ either and so we had left over TCP connections hanging around.
+
+ Until we can fix the client cleanup we rollback the use of a requests
+ session and do individual connections like we used to.
+ """
+
+ def request(self, *args, **kwargs):
+ return requests.request(*args, **kwargs)
+
+
class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
version = None
@@ -238,6 +255,7 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
self._auth_token = None
if not session:
+ kwargs['session'] = _FakeRequestSession()
session = client_session.Session.construct(kwargs)
session.auth = self