Make sure we clean up correctly after failed thrift connection
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user