diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-08-31 23:41:35 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-09-01 08:53:43 +0100 |
commit | 9f9e6d87007ea87e62495705464f4232c996a165 (patch) | |
tree | 13f9202edac11deccd8c7593071eb5a291fd5eea /lib/prserv | |
parent | 9bee497960889d9baa0a4284d79a384b18a8e826 (diff) | |
download | bitbake-contrib-9f9e6d87007ea87e62495705464f4232c996a165.tar.gz |
serv/db: Fix looping upon database locked issues
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>
Diffstat (limited to 'lib/prserv')
-rw-r--r-- | lib/prserv/db.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/prserv/db.py b/lib/prserv/db.py index 7bc198009..b7190bad0 100644 --- a/lib/prserv/db.py +++ b/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 |