summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2016-07-10 10:38:04 +0200
committerKali Kaneko <kali@leap.se>2016-07-12 03:09:33 +0200
commitf406ccbaf2b79db1d65827463f830f4ffbe5856c (patch)
treefb061e6782615ad6cb327dd8bafdb4155134ab9c
parentd99198046e07abb0d19fde1695d22267bc5e1433 (diff)
[refactor] make u1db connection pool args explicit
-rw-r--r--client/src/leap/soledad/client/adbapi.py16
-rw-r--r--testing/tests/sqlcipher/test_async.py (renamed from testing/tests/client/test_async.py)0
-rw-r--r--testing/tests/sqlcipher/test_sqlcipher.py (renamed from testing/tests/client/test_sqlcipher.py)0
-rw-r--r--testing/tests/sync/test_sqlcipher_sync.py (renamed from testing/tests/client/test_sqlcipher_sync.py)0
4 files changed, 9 insertions, 7 deletions
diff --git a/client/src/leap/soledad/client/adbapi.py b/client/src/leap/soledad/client/adbapi.py
index 234be6b6..ef0f9066 100644
--- a/client/src/leap/soledad/client/adbapi.py
+++ b/client/src/leap/soledad/client/adbapi.py
@@ -78,9 +78,11 @@ def getConnectionPool(opts, openfun=None, driver="pysqlcipher",
if openfun is None and driver == "pysqlcipher":
openfun = partial(set_init_pragmas, opts=opts)
return U1DBConnectionPool(
- "%s.dbapi2" % driver, opts=opts, sync_enc_pool=sync_enc_pool,
- database=opts.path, check_same_thread=False, cp_openfun=openfun,
- timeout=SQLCIPHER_CONNECTION_TIMEOUT)
+ opts, sync_enc_pool,
+ # the following params are relayed "as is" to twisted's
+ # ConnectionPool.
+ "%s.dbapi2" % driver, opts.path, timeout=SQLCIPHER_CONNECTION_TIMEOUT,
+ check_same_thread=False, cp_openfun=openfun)
class U1DBConnection(adbapi.Connection):
@@ -166,13 +168,12 @@ class U1DBConnectionPool(adbapi.ConnectionPool):
connectionFactory = U1DBConnection
transactionFactory = U1DBTransaction
- def __init__(self, *args, **kwargs):
+ def __init__(self, opts, sync_enc_pool, *args, **kwargs):
"""
Initialize the connection pool.
"""
- # extract soledad-specific objects from keyword arguments
- self.opts = kwargs.pop("opts")
- self._sync_enc_pool = kwargs.pop("sync_enc_pool")
+ self.opts = opts
+ self._sync_enc_pool = sync_enc_pool
try:
adbapi.ConnectionPool.__init__(self, *args, **kwargs)
except dbapi2.DatabaseError as e:
@@ -220,6 +221,7 @@ class U1DBConnectionPool(adbapi.ConnectionPool):
def _errback(failure):
failure.trap(dbapi2.OperationalError)
if failure.getErrorMessage() == "database is locked":
+ logger.warning("Database operation timed out.")
should_retry = semaphore.acquire()
if should_retry:
logger.warning(
diff --git a/testing/tests/client/test_async.py b/testing/tests/sqlcipher/test_async.py
index 42c315fe..42c315fe 100644
--- a/testing/tests/client/test_async.py
+++ b/testing/tests/sqlcipher/test_async.py
diff --git a/testing/tests/client/test_sqlcipher.py b/testing/tests/sqlcipher/test_sqlcipher.py
index 11472d46..11472d46 100644
--- a/testing/tests/client/test_sqlcipher.py
+++ b/testing/tests/sqlcipher/test_sqlcipher.py
diff --git a/testing/tests/client/test_sqlcipher_sync.py b/testing/tests/sync/test_sqlcipher_sync.py
index 3cbefc8b..3cbefc8b 100644
--- a/testing/tests/client/test_sqlcipher_sync.py
+++ b/testing/tests/sync/test_sqlcipher_sync.py