diff options
author | Ruben Pollan <meskio@sindominio.net> | 2016-01-22 02:01:17 +0100 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2016-01-22 02:01:17 +0100 |
commit | 402099735333fb27707224fb90ba1b485b380b29 (patch) | |
tree | 2155c60bff892f26234918b3359e77aa07bfd884 | |
parent | 888d3d532770cb06fbc575088dc3e27edff8d703 (diff) | |
parent | 916eaecea19f611106c2b4cea1140025c9f87ba3 (diff) |
Merge branch 'fix_sync_timeout' into develop
-rw-r--r-- | client/src/leap/soledad/client/encdecpool.py | 7 | ||||
-rw-r--r-- | common/src/leap/soledad/common/tests/test_sync_deferred.py | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/client/src/leap/soledad/client/encdecpool.py b/client/src/leap/soledad/client/encdecpool.py index 0954c1df..34667a1e 100644 --- a/client/src/leap/soledad/client/encdecpool.py +++ b/client/src/leap/soledad/client/encdecpool.py @@ -28,6 +28,7 @@ import json import logging from twisted.internet import reactor +from twisted.internet import threads from twisted.internet import defer from twisted.python import log @@ -687,7 +688,11 @@ class SyncDecrypterPool(SyncEncryptDecryptPool): """ insertable = yield self._get_insertable_docs() for doc_fields in insertable: - self._insert_decrypted_local_doc(*doc_fields) + method = self._insert_decrypted_local_doc + # FIXME: This is used only because SQLCipherU1DBSync is synchronous + # When adbapi is used there is no need for an external thread + # Without this the reactor can freeze and fail docs download + yield threads.deferToThread(method, *doc_fields) defer.returnValue(insertable) def _delete_processed_docs(self, inserted): diff --git a/common/src/leap/soledad/common/tests/test_sync_deferred.py b/common/src/leap/soledad/common/tests/test_sync_deferred.py index 90b00670..c62bd156 100644 --- a/common/src/leap/soledad/common/tests/test_sync_deferred.py +++ b/common/src/leap/soledad/common/tests/test_sync_deferred.py @@ -148,6 +148,8 @@ class TestSoledadDbSyncDeferredEncDecr( replica_uid = self._soledad._dbpool.replica_uid sync_db = self._soledad._sync_db sync_enc_pool = self._soledad._sync_enc_pool + dbsyncer = self._soledad._dbsyncer # Soledad.sync uses the dbsyncer + target = soledad_sync_target( self, self.db2._dbname, source_replica_uid=replica_uid, @@ -155,7 +157,7 @@ class TestSoledadDbSyncDeferredEncDecr( sync_enc_pool=sync_enc_pool) self.addCleanup(target.close) return sync.SoledadSynchronizer( - self.db1, + dbsyncer, target).sync(defer_decryption=True) def wait_for_sync(self): |