* serv/db: Fix looping upon database locked issues
@ 2013-08-31 22:41 Richard Purdie
0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2013-08-31 22:41 UTC (permalink / raw)
To: bitbake-devel
If the database is locked we will get an immediate error indicating so,
there is no retry timeout. The looping code is therefore useless, the loop
count is near instantly exceeded.
Using a time based retry means we can wait a sensible time, then gracefully
exit.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py
index 7bc1980..b7190ba 100644
--- a/bitbake/lib/prserv/db.py
+++ b/bitbake/lib/prserv/db.py
@@ -2,6 +2,7 @@ import logging
import os.path
import errno
import prserv
+import time
try:
import sqlite3
@@ -32,13 +33,13 @@ class PRTable(object):
def _execute(self, *query):
"""Execute a query, waiting to acquire a lock if necessary"""
- count = 0
+ start = time.time()
+ end = start + 20
while True:
try:
return self.conn.execute(*query)
except sqlite3.OperationalError as exc:
- if 'is locked' in str(exc) and count < 500:
- count = count + 1
+ if 'is locked' in str(exc) and end > time.time():
continue
raise exc
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-08-31 22:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-31 22:41 serv/db: Fix looping upon database locked issues Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.