[hive] Avoid trying to close a session not found
If not we get a: dict' object has no attribute 'get_handle'
@@ -241,23 +241,25 @@ class HS2Api(Api):
query_server = get_query_server_config(name=app_name)
response = {'status': -1, 'message': ''}
+ session_record = None
try:
filters = {'id': session_id, 'application': query_server['server_name']}
if not is_admin(self.user):
filters['owner'] = self.user
- session = Session.objects.get(**filters)
+ session_record = Session.objects.get(**filters)
except Session.DoesNotExist:
response['message'] = _('Session does not exist or you do not have permissions to close the session.')
- if session:
- session = dbms.get(self.user, query_server).close_session(session)
+ if session_record:
+ session_record = dbms.get(self.user, query_server).close_session(session_record)
response['status'] = 0
response['message'] = _('Session successfully closed.')
- response['session'] = {'id': session_id, 'application': session.application, 'status': session.status_code}
+ response['session'] = {'id': session_id, 'application': session_record.application, 'status': session_record.status_code}
return response
+
def close_session_idle(self, notebook, session):
idle = True
response = {'result': []}
