Browse Source

Database lockewd catch

Gamaliel Espinoza Macedo 6 years ago
parent
commit
eae334f89d
2 changed files with 16 additions and 3 deletions
  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
                     threads[index] = thread
                     thread.start()
                     thread.start()
+
+                except sqlite3.OperationalError as err:
+                    """ Locked database """
+                    log.error('[process_queue_with_threads] [{}] {}'.format(
+                        item['station'],
+                        err,
+                    ))
+                    continue
+
                 except Empty:
                 except Empty:
                     is_drained = True
                     is_drained = True
 
 
@@ -231,8 +240,12 @@ def process_segment(item, audios=None, calibration=None):
       b. Los audios se obtienen directamente de la base
       b. Los audios se obtienen directamente de la base
          de datos en modo de cursor.
          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
     # 2. Read the list of files from local database
     audios_counter = 0
     audios_counter = 0