From 951593776e6dabdeef69b4138e4cc3d789e6295f Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Sun, 1 May 2016 13:58:28 -0400 Subject: [feature] use deferred semaphore --- client/src/leap/soledad/client/adbapi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'client/src') 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 " -- cgit v1.2.3