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 15:51:11 +0100 |
commit | 3e5abff7da73fe35842c06cd85e2a4f50c4efa05 (patch) | |
tree | fb99cc662bf7c1c0b84544038775ae8fe121d9d5 /bitbake/lib/prserv/db.py | |
parent | b306d7d9a4dd5dec0ed1ca91b50569f078ac103e (diff) | |
download | poky-3e5abff7da73fe35842c06cd85e2a4f50c4efa05.tar.gz |
bitbake: 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.
(Bitbake rev: 9f9e6d87007ea87e62495705464f4232c996a165)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv/db.py')
-rw-r--r-- | bitbake/lib/prserv/db.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py index 7bc1980099..b7190bad01 100644 --- a/bitbake/lib/prserv/db.py +++ b/bitbake/lib/prserv/db.py | |||
@@ -2,6 +2,7 @@ import logging | |||
2 | import os.path | 2 | import os.path |
3 | import errno | 3 | import errno |
4 | import prserv | 4 | import prserv |
5 | import time | ||
5 | 6 | ||
6 | try: | 7 | try: |
7 | import sqlite3 | 8 | import sqlite3 |
@@ -32,13 +33,13 @@ class PRTable(object): | |||
32 | 33 | ||
33 | def _execute(self, *query): | 34 | def _execute(self, *query): |
34 | """Execute a query, waiting to acquire a lock if necessary""" | 35 | """Execute a query, waiting to acquire a lock if necessary""" |
35 | count = 0 | 36 | start = time.time() |
37 | end = start + 20 | ||
36 | while True: | 38 | while True: |
37 | try: | 39 | try: |
38 | return self.conn.execute(*query) | 40 | return self.conn.execute(*query) |
39 | except sqlite3.OperationalError as exc: | 41 | except sqlite3.OperationalError as exc: |
40 | if 'is locked' in str(exc) and count < 500: | 42 | if 'is locked' in str(exc) and end > time.time(): |
41 | count = count + 1 | ||
42 | continue | 43 | continue |
43 | raise exc | 44 | raise exc |
44 | 45 | ||