fix bug in queue preventing actions with null values from being purged
This commit is contained in:
parent
934d5a4ca6
commit
7d94be516f
1 changed files with 18 additions and 8 deletions
|
@ -14,6 +14,7 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import traceback
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,14 +61,13 @@ class Queue(object):
|
||||||
|
|
||||||
|
|
||||||
def pop(self):
|
def pop(self):
|
||||||
return None
|
|
||||||
tries = 3
|
tries = 3
|
||||||
wait = 0.1
|
wait = 0.1
|
||||||
action = None
|
action = None
|
||||||
try:
|
try:
|
||||||
conn, c = self.connect()
|
conn, c = self.connect()
|
||||||
except sqlite3.Error, e:
|
except sqlite3.Error, e:
|
||||||
log.debug(str(e))
|
log.debug(traceback.format_exc())
|
||||||
return None
|
return None
|
||||||
loop = True
|
loop = True
|
||||||
while loop and tries > -1:
|
while loop and tries > -1:
|
||||||
|
@ -76,10 +76,20 @@ class Queue(object):
|
||||||
c.execute('SELECT * FROM action LIMIT 1')
|
c.execute('SELECT * FROM action LIMIT 1')
|
||||||
row = c.fetchone()
|
row = c.fetchone()
|
||||||
if row is not None:
|
if row is not None:
|
||||||
log.info(row)
|
values = []
|
||||||
c.execute('''DELETE FROM action WHERE
|
clauses = []
|
||||||
file=? AND time=? AND project=? AND language=? AND
|
index = 0
|
||||||
lines=? AND branch=? AND is_write=?''', row[0:7])
|
for row_name in ['file', 'time', 'project', 'language', 'lines', 'branch', 'is_write']:
|
||||||
|
if row[index] is not None:
|
||||||
|
clauses.append('{0}=?'.format(row_name))
|
||||||
|
values.append(row[index])
|
||||||
|
else:
|
||||||
|
clauses.append('{0} IS NULL'.format(row_name))
|
||||||
|
index += 1
|
||||||
|
if len(values) > 0:
|
||||||
|
c.execute('DELETE FROM action WHERE {0}'.format(u' AND '.join(clauses)), values)
|
||||||
|
else:
|
||||||
|
c.execute('DELETE FROM action WHERE {0}'.format(u' AND '.join(clauses)))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
if row is not None:
|
if row is not None:
|
||||||
action = {
|
action = {
|
||||||
|
@ -94,11 +104,11 @@ class Queue(object):
|
||||||
}
|
}
|
||||||
loop = False
|
loop = False
|
||||||
except sqlite3.Error, e:
|
except sqlite3.Error, e:
|
||||||
log.debug(str(e))
|
log.debug(traceback.format_exc())
|
||||||
sleep(wait)
|
sleep(wait)
|
||||||
tries -= 1
|
tries -= 1
|
||||||
try:
|
try:
|
||||||
conn.close()
|
conn.close()
|
||||||
except sqlite3.Error, e:
|
except sqlite3.Error, e:
|
||||||
log.debug(str(e))
|
log.debug(traceback.format_exc())
|
||||||
return action
|
return action
|
||||||
|
|
Loading…
Reference in a new issue