From 01557be5c80833b27df46f4eab17b29c53a7245b Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Fri, 20 Dec 2013 11:33:29 -0400 Subject: catch cannotsendrequest exception --- client/src/leap/soledad/client/sqlcipher.py | 18 ++++++++++++++++-- 1 file 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): -- cgit v1.2.3