summaryrefslogtreecommitdiff
path: root/client/src/leap/soledad
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2016-01-20 07:54:35 -0300
committerVictor Shyba <victor.shyba@gmail.com>2016-01-21 17:58:21 -0300
commit4c214b7ff9351dd98efbb033dd5e09b8ff9ff763 (patch)
tree4a833fb47547c2593e58e2c35c735737d7265458 /client/src/leap/soledad
parent888d3d532770cb06fbc575088dc3e27edff8d703 (diff)
[Fix] slow IO-bound calls block reactor
- Move them to a thread so reactor can continue processing e.g. http requests
Diffstat (limited to 'client/src/leap/soledad')
-rw-r--r--client/src/leap/soledad/client/encdecpool.py7
1 files changed, 6 insertions, 1 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):