in theory this waits up until 20 seconds before raising locked

This commit is contained in:
Nikos Kouremenos 2005-11-27 12:22:07 +00:00
parent 958512e90d
commit 31c29fb56a
1 changed files with 8 additions and 6 deletions

View File

@ -89,7 +89,10 @@ class Logger:
return return
global con, cur global con, cur
con = sqlite.connect(LOG_DB_PATH) # if locked, wait up to 20 sec to unlock
# before raise (hopefully should be enough)
con = sqlite.connect(LOG_DB_PATH, timeout = 20.0,
isolation_level = 'IMMEDIATE')
cur = con.cursor() cur = con.cursor()
self.get_jids_already_in_db() self.get_jids_already_in_db()
@ -118,10 +121,8 @@ class Logger:
(possible_room_jid, constants.JID_ROOM_TYPE)) (possible_room_jid, constants.JID_ROOM_TYPE))
row = cur.fetchone() row = cur.fetchone()
if row is not None: if row is not None:
print 'PM!!'
return True return True
else: # FIXME: THIS NEVER HAPPENS? else:
print ' NO PM!!'
return False return False
def get_jid_id(self, jid, typestr = None): def get_jid_id(self, jid, typestr = None):
@ -209,7 +210,8 @@ class Logger:
if not GOT_JIDS_ALREADY_IN_DB: if not GOT_JIDS_ALREADY_IN_DB:
global con, cur global con, cur
con = sqlite.connect(LOG_DB_PATH) con = sqlite.connect(LOG_DB_PATH, timeout = 20.0,
isolation_level = 'IMMEDIATE')
cur = con.cursor() cur = con.cursor()
self.get_jids_already_in_db() self.get_jids_already_in_db()
@ -316,7 +318,7 @@ class Logger:
results = cur.fetchall() results = cur.fetchall()
return results return results
def date_has_logs(self, jid, year, month, day): def date_has_logs(self, jid, year, month, day):
'''returns True if we have logs for given day, else False''' '''returns True if we have logs for given day, else False'''
jid = jid.lower() jid = jid.lower()