diff --git a/BackupPC_archiveHost_s3 b/BackupPC_archiveHost_s3 index 1b41493..88621ba 100755 --- a/BackupPC_archiveHost_s3 +++ b/BackupPC_archiveHost_s3 @@ -74,7 +74,7 @@ class SlowFile: self.encoding = None self.delayfactor = 1 - self.lastblocktargettime = None + self.lastblocktargettime = 2**31 self.lastdebug = 0 @@ -111,7 +111,7 @@ class SlowFile: self.delayfactor -= 0.02 else: # we're late; something got slow. - self.delayfactor += 0.01 + self.delayfactor += 0.5 if self.delayfactor < 1: self.delayfactor = 1 @@ -121,8 +121,20 @@ class SlowFile: targetspeed = self.speed/float(self.delayfactor) self.lastblocktargettime = time.time() + len/float(targetspeed) - if time.time() > self.lastdebug+60: + if time.time() > self.lastdebug+300: logger.debug('Target %i bytes/second (%i kilobits/second), delay factor %.2f, block len %i' % (targetspeed, targetspeed*8/1024, self.delayfactor, len)) + try: + newkbits = int(open('/home/rtucker/Dropbox/Semaphores/BackupPC_archiveHost_s3.maxspeed', 'r').readline()) + newspeed = (newkbits/float(8))*1024 + if newspeed != self.speed: + self.delayfactor = 1 + self.speed = newspeed + logger.debug('Setting new speed! %i bytes/second' % newspeed) + except IOError: + logger.debug('No Semaphore file for new speed') + except ValueError: + logger.debug('Semaphore file invalid') + self.lastdebug = time.time() return self.fd.read(len)