Bladeren bron

Database lockewd catch

Gamaliel Espinoza Macedo 6 jaren geleden
bovenliggende
commit
eae334f89d
2 gewijzigde bestanden met toevoegingen van 16 en 3 verwijderingen
  1. 1 1
      ondemand/__init__.py
  2. 15 2
      ondemand/service.py

+ 1 - 1
ondemand/__init__.py

@@ -1 +1 @@
-__version__ = '1.3.2-rc2'
+__version__ = '1.3.2-rc3'

+ 15 - 2
ondemand/service.py

@@ -157,6 +157,15 @@ def process_queue_with_threads():
                     )
                     threads[index] = thread
                     thread.start()
+
+                except sqlite3.OperationalError as err:
+                    """ Locked database """
+                    log.error('[process_queue_with_threads] [{}] {}'.format(
+                        item['station'],
+                        err,
+                    ))
+                    continue
+
                 except Empty:
                     is_drained = True
 
@@ -231,8 +240,12 @@ def process_segment(item, audios=None, calibration=None):
       b. Los audios se obtienen directamente de la base
          de datos en modo de cursor.
     """
-    audios_iterable = audios if audios \
-        else iterate_audios(date, station, calibration=calibration)
+    try:
+        audios_iterable = audios if audios \
+            else iterate_audios(date, station, calibration=calibration)
+    except sqlite3.OperationalError as err:
+        log.error('[process_segment] [{}] {}'.format(station, err))
+        return
 
     # 2. Read the list of files from local database
     audios_counter = 0