Make sure we clean up correctly after failed thrift connection

This commit is contained in:
Honza Král
2014-01-18 21:33:04 +01:00
parent 2a76e66dea
commit c82219ea0a
+3 -1
View File
@@ -56,6 +56,7 @@ class ThriftConnection(PoolingConnection):
parameters=params, body=body)
start = time.time()
tclient = None
try:
tclient = self._get_connection()
response = tclient.execute(request)
@@ -64,7 +65,8 @@ class ThriftConnection(PoolingConnection):
self.log_request_fail(method, url, body, time.time() - start, exception=e)
raise ConnectionError('N/A', str(e), e)
finally:
self._release_connection(tclient)
if tclient:
self._release_connection(tclient)
if not (200 <= response.status < 300) and response.status not in ignore:
self.log_request_fail(method, url, body, duration, response.status)