From f87dbdafc989f7bdda2725908f31b3b9c55fbd8d Mon Sep 17 00:00:00 2001 From: Ryan Tucker Date: Mon, 18 Jan 2010 17:06:05 -0500 Subject: [PATCH] some tweaks to speed rollback logic --- BackupPC_archiveHost_s3 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/BackupPC_archiveHost_s3 b/BackupPC_archiveHost_s3 index 85d2645..a7241a3 100755 --- a/BackupPC_archiveHost_s3 +++ b/BackupPC_archiveHost_s3 @@ -119,8 +119,9 @@ class SlowFile: time.sleep(sleepfor) else: # we're late; something got slow. - self.delayfactor += 0.5 - logger.debug('%.2f seconds late (congestion?); setting delayfactor to %.2f' % (starttime - self.lastblocktargettime, self.delayfactor)) + lateness = starttime - self.lastblocktargettime + self.delayfactor += lateness + logger.debug('%.2f seconds late (congestion?); setting delayfactor to %.2f' % (lateness, self.delayfactor)) targetspeed = self.speed/float(self.delayfactor) self.lastblocktargettime = time.time() + len/float(targetspeed) @@ -128,7 +129,7 @@ class SlowFile: if time.time() > self.lastdebug+300: if self.delayfactor > 1: # reduce the penalty a bit - self.delayfactor = self.delayfactor / 2.0 + self.delayfactor -= 0.1 if self.delayfactor < 1: self.delayfactor = 1 @@ -317,7 +318,7 @@ for i in sorted(glob.glob(fileglob)): key.set_acl('private') key.close() retry_count = max_retries+1 - except boto.exception.S3ResponseError, socket.error as e: + except (boto.exception.S3ResponseError, socket.error) as e: retry_count += 1 sleeptime = 2**retry_count err = 'Encountered exception %s, retrying in %i seconds (%i/%i)' % (e, sleeptime, retry_count, max_retries)