From cc73e77a3c3593ff33c7cf014035857ed3d54770 Mon Sep 17 00:00:00 2001 From: Ryan Tucker Date: Sat, 2 Jan 2010 19:32:16 -0500 Subject: [PATCH] more tweaks to the rate limiting code --- BackupPC_archiveHost_s3 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/BackupPC_archiveHost_s3 b/BackupPC_archiveHost_s3 index ddc9722..1c88857 100755 --- a/BackupPC_archiveHost_s3 +++ b/BackupPC_archiveHost_s3 @@ -113,19 +113,23 @@ class SlowFile: else: # we're late; something got slow. self.delayfactor += 0.5 - logger.debug('%.2f late (congestion?); setting delayfactor to %.2f' % (starttime - self.lastblocktargettime, self.delayfactor)) - - if self.delayfactor < 1: - self.delayfactor = 1 - if self.delayfactor > 20: - self.delayfactor = 20 + logger.debug('%.2f seconds late (congestion?); setting delayfactor to %.2f' % (starttime - self.lastblocktargettime, self.delayfactor)) targetspeed = self.speed/float(self.delayfactor) self.lastblocktargettime = time.time() + len/float(targetspeed) if time.time() > self.lastdebug+300: + if self.delayfactor > 1: + # reduce the penalty a bit + self.delayfactor = self.delayfactor / 2.0 + + if self.delayfactor < 1: + self.delayfactor = 1 + if self.delayfactor > 20: + self.delayfactor = 20 + logger.debug('Target %i bytes/second (%i kilobits/second), delay factor %.2f, block len %i' % (targetspeed, targetspeed*8/1024, self.delayfactor, len)) - self.delayfactor = self.delayfactor / 2 + try: newkbits = int(open('/home/rtucker/Dropbox/Semaphores/BackupPC_archiveHost_s3.maxspeed', 'r').readline()) newspeed = int((newkbits/float(8))*1024)