diff options
author | Kali Kaneko <kali@leap.se> | 2013-12-20 11:33:29 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2013-12-20 11:33:29 -0400 |
commit | 01557be5c80833b27df46f4eab17b29c53a7245b (patch) | |
tree | 0c52ac17ce718bdf02d06b9e277b69b7f098749d /client/src/leap/soledad | |
parent | 3a38c1b92e6f1e538f682e4e0f7e99a18f41d7d0 (diff) |
catch cannotsendrequest exception
Diffstat (limited to 'client/src/leap/soledad')
-rw-r--r-- | client/src/leap/soledad/client/sqlcipher.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py index 5695bf82..43c871c3 100644 --- a/client/src/leap/soledad/client/sqlcipher.py +++ b/client/src/leap/soledad/client/sqlcipher.py @@ -43,11 +43,12 @@ So, as the statements above were introduced for backwards compatibility with SLCipher 1.1 databases, we do not implement them as all SQLCipher databases handled by Soledad should be created by SQLCipher >= 2.0. """ +import httplib import logging import os -import time import string import threading +import time from pysqlcipher import dbapi2 from u1db.backends import sqlite_backend @@ -341,7 +342,20 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase): """ if not self.syncer: self._create_syncer(url, creds=creds) - return self.syncer.sync(autocreate=autocreate) + + try: + res = self.syncer.sync(autocreate=autocreate) + except httplib.CannotSendRequest: + # raised when you reuse httplib.HTTP object for new request + # while you havn't called its getresponse() + # this catch works for the current connclass used + # by our HTTPClientBase, since it uses httplib. + # we will have to replace it if it changes. + logger.info("Replacing connection and trying again...") + self._syncer = None + self._create_syncer(url, creds=creds) + res = self.syncer.sync(autocreate=autocreate) + return res @property def syncer(self): |