summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-04-04 15:52:39 -0300
committerTomás Touceda <chiiph@leap.se>2014-04-04 15:52:39 -0300
commiteb6af9fd66d0c69af6735ffbd08fe86c3ccf313a (patch)
treeae7714d1133600fcefe71e3e9441f2a987232eb3 /common
parent0d283e11e094e8537f3e8e4879aeca69169cffd1 (diff)
parent86890a496ba05951573dad7f69fa2840087994d2 (diff)
Merge remote-tracking branch 'refs/remotes/drebs/bug/5449_preload-strptime-to-avoid-multi-thread-problem' into develop
Diffstat (limited to 'common')
-rw-r--r--common/changes/bug_5449_preload-strptime-to-avoid-multi-thread-problem2
-rw-r--r--common/src/leap/soledad/common/couch.py11
2 files changed, 13 insertions, 0 deletions
diff --git a/common/changes/bug_5449_preload-strptime-to-avoid-multi-thread-problem b/common/changes/bug_5449_preload-strptime-to-avoid-multi-thread-problem
new file mode 100644
index 00000000..17d1f463
--- /dev/null
+++ b/common/changes/bug_5449_preload-strptime-to-avoid-multi-thread-problem
@@ -0,0 +1,2 @@
+ o Preload time.strptime() to avoid multi-threaded problem on couch backend
+ get_docs() method (#5449).
diff --git a/common/src/leap/soledad/common/couch.py b/common/src/leap/soledad/common/couch.py
index 1bb84985..8e8613a1 100644
--- a/common/src/leap/soledad/common/couch.py
+++ b/common/src/leap/soledad/common/couch.py
@@ -1401,6 +1401,17 @@ class CouchDatabase(CommonBackend):
in matching doc_ids order.
:rtype: iterable
"""
+ # Workaround for:
+ #
+ # http://bugs.python.org/issue7980
+ # https://leap.se/code/issues/5449
+ #
+ # python-couchdb uses time.strptime, which is not thread safe. In
+ # order to avoid the problem described on the issues above, we preload
+ # strptime here by evaluating the conversion of an arbitrary date.
+ # This will not be needed when/if we switch from python-couchdb to
+ # paisley.
+ time.strptime('Mar 4 1917', '%b %d %Y')
# spawn threads to retrieve docs
threads = []
for doc_id in doc_ids: