소스 검색

[presto] Avoid exception when no progress stats

Romain Rigaux 4 년 전
부모
커밋
807c2a7833
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 4
      desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

+ 4 - 4
desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

@@ -315,15 +315,15 @@ class SqlAlchemyApi(Api):
       guid = snippet['result']['handle']['guid']
       guid = snippet['result']['handle']['guid']
       handle = CONNECTIONS.get(guid)
       handle = CONNECTIONS.get(guid)
       stats = None
       stats = None
+      progress = 100
       try:
       try:
         if handle:
         if handle:
           stats = handle['result'].cursor.poll()
           stats = handle['result'].cursor.poll()
       except AssertionError as e:
       except AssertionError as e:
         LOG.warn('Query probably not running anymore: %s' % e)
         LOG.warn('Query probably not running anymore: %s' % e)
-      if not stats:
-        progress = 100
-      stats = stats.get('stats', {})
-      return stats.get('completedSplits', 0) * 100 // stats.get('totalSplits', 1)
+      if stats:
+        stats = stats.get('stats', {})
+        progress = stats.get('completedSplits', 0) * 100 // stats.get('totalSplits', 1)
     return progress
     return progress