catch sql errors

This commit is contained in:
Clint Armstrong 2015-07-13 11:10:14 -04:00
parent 9f1c2232f0
commit 3ff7a48089

View File

@ -231,7 +231,10 @@ while True:
' time_taken=values(time_taken) ').format(config['distributed_poller_name'].strip(),
devices_scanned,
seconds_taken)
cursor.execute(update_query)
try:
cursor.execute(update_query)
except:
log.critical('ERROR: MySQL query error. Is your schema up to date?')
cursor.fetchall()
log.info('INFO: {} devices scanned in the last 5 minutes'.format(devices_scanned))
devices_scanned = 0
@ -240,7 +243,11 @@ while True:
while threading.active_count() >= amount_of_workers:
time.sleep(.5)
cursor.execute(dev_query)
try:
cursor.execute(dev_query)
except:
log.critical('ERROR: MySQL query error. Is your schema up to date?')
devices = cursor.fetchall()
for device_id, next_poll, next_discovery in devices:
# add queue lock, so we lock the next device against any other pollers