def generateToken(self):
    retry_count = 0
    incr_sleep = 10
    while (retry_count <= self.connection_retry_count):
        try:
            acquired = connection_lock.acquire()
            swiftconn = swiftclient.client.Connection(authurl=self.authurl, user=self.user, key=self.key, preauthtoken=self.preauthtoken, tenant_name=self.tenant_name, auth_version=self.auth_version, timeout=self.conn_timeout_sec, insecure=True)
            self.swift_conn = swiftconn
            swiftconn.get_account()
            self.storageurl = swiftconn.url
            break
        except Exception as e:
            retry_count += 1
            err_msg = e.message
            logging.error(err_msg)
            if (retry_count == self.connection_retry_count):
                raise Exception(('Connection failed with swift server: ' + str(err_msg)))
            logging.error('Connection failed with swift server, retrying..')
            incr_sleep *= 2
            time.sleep(incr_sleep)
        finally:
            if acquired:
                connection_lock.release()
def generateToken(self):
    retry_count = 0
    incr_sleep = 10
    while (retry_count <= self.connection_retry_count):
        try:
            acquired = connection_lock.acquire()
            swiftconn = swiftclient.client.Connection(authurl=self.authurl, user=self.user, key=self.key, preauthtoken=self.preauthtoken, tenant_name=self.tenant_name, auth_version=self.auth_version, timeout=self.conn_timeout_sec, insecure=True)
            self.swift_conn = swiftconn
            swiftconn.get_account()
            self.storageurl = swiftconn.url
            break
        except Exception as e:
            retry_count += 1
            err_msg = e.message
            logging.error(err_msg)
            if (retry_count == self.connection_retry_count):
                raise Exception(('Connection failed with swift server: ' + str(err_msg)))
            logging.error('Connection failed with swift server, retrying..')
            incr_sleep *= 2
            time.sleep(incr_sleep)
        finally:
            if acquired:
                connection_lock.release()