Suggest downloading when server is out of ram
authorKarl O. Pinc <kop@karlpinc.com>
Mon, 30 Sep 2024 00:39:08 +0000 (19:39 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Mon, 30 Sep 2024 00:39:08 +0000 (19:39 -0500)
src/pgwui_sql/exceptions.py
src/pgwui_sql/views/sql.py

index 3a8d532109aa4efb5d09340b1effb3df714fb9c5..310a76ec10df8eaf96c1fe4d668a51bf6ae2dc38 100644 (file)
@@ -82,3 +82,18 @@ class CSVError(SQLError):
     def __init__(self, descr='', detail=''):
         super().__init__('Error while formatting the download',
                          '', descr=descr, detail=detail)
+
+
+class MemoryError(SQLError):
+    '''
+    Error raised when we run out of memory generating on-screen results
+
+    descr  More description of the error
+    detail Extra HTML describing the error
+    '''
+    def __init__(self,
+                 descr=("Can't collect results for on-screen display"
+                        '-- try downloading instead'),
+                 detail=''):
+        super().__init__('Webserver out of memory',
+                         '', descr=descr, detail=detail)
index c39fc3436a08106211e687b0931e2d7b5c1385a6..fc02e53da4eb715126277174a6e7db661f7c140a 100644 (file)
@@ -339,7 +339,11 @@ class SQLResultsHandler(pgwui_core.core.SessionDBHandler):
             except csv.Error as ex:
                 raise sql_ex.CSVError(descr=f'The csv module reports: {ex}')
         else:
-            self.make_sql_results(cur)
+            try:
+                self.make_sql_results(cur)
+            except MemoryError:
+                self.sql_results = []
+                raise sql_ex.MemoryError()
 
     def factory(self, ue):
         '''Make a db loader function from an UploadEngine.