summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2016-05-01 13:58:28 -0400
committerKali Kaneko <kali@leap.se>2016-06-06 19:58:50 -0400
commit951593776e6dabdeef69b4138e4cc3d789e6295f (patch)
treeeb27805b9f0686908d3f7e987fc8c12118c42f2c
parent06f3c80e848b14d3fff1a6edd2cd58f998b976db (diff)
[feature] use deferred semaphore
-rw-r--r--client/changes/next-changelog.rst1
-rw-r--r--client/src/leap/soledad/client/adbapi.py6
2 files changed, 4 insertions, 3 deletions
diff --git a/client/changes/next-changelog.rst b/client/changes/next-changelog.rst
index 050d84be..a696fe10 100644
--- a/client/changes/next-changelog.rst
+++ b/client/changes/next-changelog.rst
@@ -10,6 +10,7 @@ I've added a new category `Misc` so we can track doc/style/packaging stuff.
Features
~~~~~~~~
+- Use DeferredLock instead of its locking cousin.
- `#1234 <https://leap.se/code/issues/1234>`_: Description of the new feature corresponding with issue #1234.
- New feature without related issue number.
diff --git a/client/src/leap/soledad/client/adbapi.py b/client/src/leap/soledad/client/adbapi.py
index 77822247..f43e8110 100644
--- a/client/src/leap/soledad/client/adbapi.py
+++ b/client/src/leap/soledad/client/adbapi.py
@@ -24,9 +24,9 @@ import sys
import logging
from functools import partial
-from threading import BoundedSemaphore
from twisted.enterprise import adbapi
+from twisted.internet.defer import DeferredSemaphore
from twisted.python import log
from zope.proxy import ProxyBase, setProxiedObject
from pysqlcipher.dbapi2 import OperationalError
@@ -204,7 +204,7 @@ class U1DBConnectionPool(adbapi.ConnectionPool):
:rtype: twisted.internet.defer.Deferred
"""
meth = "u1db_%s" % meth
- semaphore = BoundedSemaphore(SQLCIPHER_MAX_RETRIES - 1)
+ semaphore = DeferredSemaphore(SQLCIPHER_MAX_RETRIES )
def _run_interaction():
return self.runInteraction(
@@ -213,7 +213,7 @@ class U1DBConnectionPool(adbapi.ConnectionPool):
def _errback(failure):
failure.trap(OperationalError)
if failure.getErrorMessage() == "database is locked":
- should_retry = semaphore.acquire(False)
+ should_retry = semaphore.acquire()
if should_retry:
logger.warning(
"Database operation timed out while waiting for "