more tweaks to the rate limiting code
This commit is contained in:
parent
484922d4ef
commit
cc73e77a3c
1 changed files with 11 additions and 7 deletions
|
@ -113,19 +113,23 @@ class SlowFile:
|
||||||
else:
|
else:
|
||||||
# we're late; something got slow.
|
# we're late; something got slow.
|
||||||
self.delayfactor += 0.5
|
self.delayfactor += 0.5
|
||||||
logger.debug('%.2f late (congestion?); setting delayfactor to %.2f' % (starttime - self.lastblocktargettime, self.delayfactor))
|
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:
|
if self.delayfactor < 1:
|
||||||
self.delayfactor = 1
|
self.delayfactor = 1
|
||||||
if self.delayfactor > 20:
|
if self.delayfactor > 20:
|
||||||
self.delayfactor = 20
|
self.delayfactor = 20
|
||||||
|
|
||||||
targetspeed = self.speed/float(self.delayfactor)
|
|
||||||
self.lastblocktargettime = time.time() + len/float(targetspeed)
|
|
||||||
|
|
||||||
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))
|
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:
|
try:
|
||||||
newkbits = int(open('/home/rtucker/Dropbox/Semaphores/BackupPC_archiveHost_s3.maxspeed', 'r').readline())
|
newkbits = int(open('/home/rtucker/Dropbox/Semaphores/BackupPC_archiveHost_s3.maxspeed', 'r').readline())
|
||||||
newspeed = int((newkbits/float(8))*1024)
|
newspeed = int((newkbits/float(8))*1024)
|
||||||
|
|
Loading…
Reference in a new issue