|
21 | 21 | from lib.core.settings import HASHDB_END_TRANSACTION_RETRIES |
22 | 22 | from lib.core.settings import HASHDB_FLUSH_RETRIES |
23 | 23 | from lib.core.settings import HASHDB_FLUSH_THRESHOLD |
| 24 | +from lib.core.settings import HASHDB_RETRIEVE_RETRIES |
24 | 25 | from lib.core.settings import UNICODE_ENCODING |
25 | 26 | from lib.core.threads import getCurrentThreadData |
26 | 27 | from lib.core.threads import getCurrentThreadName |
@@ -76,16 +77,18 @@ def retrieve(self, key, unserialize=False): |
76 | 77 | hash_ = HashDB.hashKey(key) |
77 | 78 | retVal = self._write_cache.get(hash_) |
78 | 79 | if not retVal: |
79 | | - while True: |
| 80 | + for _ in xrange(HASHDB_RETRIEVE_RETRIES): |
80 | 81 | try: |
81 | 82 | for row in self.cursor.execute("SELECT value FROM storage WHERE id=?", (hash_,)): |
82 | 83 | retVal = row[0] |
83 | 84 | except sqlite3.OperationalError, ex: |
84 | | - if not any(_ in getSafeExString(ex) for _ in ("locked", "no such table")): |
85 | | - raise |
86 | | - else: |
| 85 | + if any(_ in getSafeExString(ex) for _ in ("locked", "no such table")): |
87 | 86 | warnMsg = "problem occurred while accessing session file '%s' ('%s')" % (self.filepath, getSafeExString(ex)) |
88 | 87 | singleTimeWarnMessage(warnMsg) |
| 88 | + elif "Could not decode" in getSafeExString(ex): |
| 89 | + break |
| 90 | + else: |
| 91 | + raise |
89 | 92 | except sqlite3.DatabaseError, ex: |
90 | 93 | errMsg = "error occurred while accessing session file '%s' ('%s'). " % (self.filepath, getSafeExString(ex)) |
91 | 94 | errMsg += "If the problem persists please rerun with `--flush-session`" |
|
0 commit comments