Close Cursor objects explicitly
This commit is contained in:
@@ -26,14 +26,17 @@ class Greylist(object):
|
|||||||
"Delete records past the retention limit."
|
"Delete records past the retention limit."
|
||||||
now = time.time() + timeinc - self.greylist_retain
|
now = time.time() + timeinc - self.greylist_retain
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
|
try:
|
||||||
cur.execute('delete from greylist where lastseen < ?',(now,))
|
cur.execute('delete from greylist where lastseen < ?',(now,))
|
||||||
cnt = cur.rowcount
|
cnt = cur.rowcount
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
finally: cur.close()
|
||||||
return cnt
|
return cnt
|
||||||
|
|
||||||
def check(self,ip,sender,recipient,timeinc=0):
|
def check(self,ip,sender,recipient,timeinc=0):
|
||||||
"Return number of allowed messages for greylist triple."
|
"Return number of allowed messages for greylist triple."
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
|
try:
|
||||||
cur.execute('''select firstseen,lastseen,cnt,umis from greylist where
|
cur.execute('''select firstseen,lastseen,cnt,umis from greylist where
|
||||||
ip=? and sender=? and recipient=?''',(ip,sender,recipient))
|
ip=? and sender=? and recipient=?''',(ip,sender,recipient))
|
||||||
r = cur.fetchone()
|
r = cur.fetchone()
|
||||||
@@ -70,6 +73,7 @@ class Greylist(object):
|
|||||||
where ip=? and sender=? and recipient=?''',
|
where ip=? and sender=? and recipient=?''',
|
||||||
(now,now,0,None,ip,sender,recipient))
|
(now,now,0,None,ip,sender,recipient))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
finally: cur.close()
|
||||||
return cnt
|
return cnt
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user