summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-08-26 00:24:08 +0000
committerGerrit Code Review <review@openstack.org>2014-08-26 00:24:08 +0000
commitaee756708b3806d1a396596660e8eb733b026824 (patch)
treea33b3d64c3b6fa61b7f099c6647392f6ba004a0b
parentee6b2f2c0557f062a9ade54808140d3477101697 (diff)
parent8fcacdc7c74f5ac68e8e55ea8c15918c452411fe (diff)
downloadpython-keystoneclient-aee756708b3806d1a396596660e8eb733b026824.tar.gz
Merge "Move fake session to HTTPClient"
-rw-r--r--keystoneclient/httpclient.py18
-rw-r--r--keystoneclient/session.py18
2 files changed, 19 insertions, 17 deletions
diff --git a/keystoneclient/httpclient.py b/keystoneclient/httpclient.py
index d9fe955..7c1af06 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
diff --git a/keystoneclient/session.py b/keystoneclient/session.py
index 26b95e1..a923a64 100644
--- a/keystoneclient/session.py
+++ b/keystoneclient/session.py
@@ -49,22 +49,6 @@ def request(url, method='GET', **kwargs):
return Session().request(url, method=method, **kwargs)
-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 Session(object):
user_agent = None
@@ -113,7 +97,7 @@ class Session(object):
for forever/never. (optional, default to 30)
"""
if not session:
- session = _FakeRequestSession()
+ session = requests.Session()
self.auth = auth
self.session = session