aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Shepelev <temotor@gmail.com>2018-08-14 01:07:36 +0500
committerSergey Shepelev <temotor@gmail.com>2018-08-14 12:34:41 +0500
commit211d6f07dc5fdb9339c525f746ad8944967a1ea9 (patch)
tree6c33b91f8dd8157ffd29bff9b481556fbb4866e2
parentaa1b95b2858ddc7a2f1f1ae07000cfe478f6e340 (diff)
downloadhttplib2-211d6f07dc5fdb9339c525f746ad8944967a1ea9.tar.gz
eliminate connection pool read race; Thanks to Justin Israel
https://github.com/httplib2/httplib2/issues/33
-rw-r--r--python2/httplib2/__init__.py5
-rw-r--r--python3/httplib2/__init__.py5
2 files changed, 4 insertions, 6 deletions
diff --git a/python2/httplib2/__init__.py b/python2/httplib2/__init__.py
index d1e0ed5..1d66904 100644
--- a/python2/httplib2/__init__.py
+++ b/python2/httplib2/__init__.py
@@ -1949,9 +1949,8 @@ class Http(object):
proxy_info = self._get_proxy_info(scheme, authority)
conn_key = scheme + ":" + authority
- if conn_key in self.connections:
- conn = self.connections[conn_key]
- else:
+ conn = self.connections.get(conn_key)
+ if conn is None:
if not connection_type:
connection_type = SCHEME_TO_CONNECTION[scheme]
certs = list(self.certificates.iter(authority))
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py
index 5d9adec..3983d16 100644
--- a/python3/httplib2/__init__.py
+++ b/python3/httplib2/__init__.py
@@ -1739,9 +1739,8 @@ a string that contains the response entity body.
authority = domain_port[0]
conn_key = scheme + ":" + authority
- if conn_key in self.connections:
- conn = self.connections[conn_key]
- else:
+ conn = self.connections.get(conn_key)
+ if conn is None:
if not connection_type:
connection_type = SCHEME_TO_CONNECTION[scheme]
certs = list(self.certificates.iter(authority))