Browse Source

[spark] Fix retry of re-creation of an expired session

Romain Rigaux 10 years ago
parent
commit
1ceaf09
1 changed files with 6 additions and 6 deletions
  1. 6 6
      apps/spark/src/spark/models.py

+ 6 - 6
apps/spark/src/spark/models.py

@@ -263,15 +263,15 @@ class SparkApi():
   def execute(self, notebook, snippet):
   def execute(self, notebook, snippet):
     api = get_spark_api(self.user)
     api = get_spark_api(self.user)
     session = _get_snippet_session(notebook, snippet)
     session = _get_snippet_session(notebook, snippet)
-    response = api.submit_statement(session['id'], snippet['statement'])
 
 
     try:
     try:
+      response = api.submit_statement(session['id'], snippet['statement'])
       return {
       return {
           'id': response['id'],
           'id': response['id'],
           'has_result_set': True,
           'has_result_set': True,
       }
       }
     except Exception, e:
     except Exception, e:
-      message = force_unicode(str(e))
+      message = force_unicode(str(e)).lower()
       if 'session not found' in message:
       if 'session not found' in message:
         raise SessionExpired(e)
         raise SessionExpired(e)
       else:
       else:
@@ -280,15 +280,15 @@ class SparkApi():
   def check_status(self, notebook, snippet):
   def check_status(self, notebook, snippet):
     api = get_spark_api(self.user)
     api = get_spark_api(self.user)
     session = _get_snippet_session(notebook, snippet)
     session = _get_snippet_session(notebook, snippet)
-    cell = snippet['result']['handle']['id']
-    response = api.fetch_data(session['id'], cell)
+    cell = snippet['result']['handle']['id']    
 
 
     try:
     try:
+      response = api.fetch_data(session['id'], cell)
       return {
       return {
           'status': response['state'],
           'status': response['state'],
       }
       }
     except Exception, e:
     except Exception, e:
-      message = force_unicode(str(e))
+      message = force_unicode(str(e)).lower()
       if 'session not found' in message:
       if 'session not found' in message:
         raise SessionExpired(e)
         raise SessionExpired(e)
       else:
       else:
@@ -302,7 +302,7 @@ class SparkApi():
     try:
     try:
       data = api.fetch_data(session['id'], cell)
       data = api.fetch_data(session['id'], cell)
     except Exception, e:
     except Exception, e:
-      message = force_unicode(str(e))
+      message = force_unicode(str(e)).lower()
       if 'session not found' in message:
       if 'session not found' in message:
         raise SessionExpired(e)
         raise SessionExpired(e)
       else:
       else: