Download fixes
- don't make empty requests - don't make requests if all objects are pending already
This commit is contained in:
parent
57c8c7c07c
commit
053f434e04
|
@ -62,6 +62,8 @@ class DownloadThread(threading.Thread, StoppableThread):
|
||||||
continue
|
continue
|
||||||
payload.extend(chunk)
|
payload.extend(chunk)
|
||||||
missingObjects[chunk] = now
|
missingObjects[chunk] = now
|
||||||
|
if not payload:
|
||||||
|
continue
|
||||||
i.append_write_buf(protocol.CreatePacket('getdata', payload))
|
i.append_write_buf(protocol.CreatePacket('getdata', payload))
|
||||||
logger.debug("%s:%i Requesting %i objects", i.destination.host, i.destination.port, len(request))
|
logger.debug("%s:%i Requesting %i objects", i.destination.host, i.destination.port, len(request))
|
||||||
requested += len(request)
|
requested += len(request)
|
||||||
|
|
|
@ -71,8 +71,9 @@ class RandomTrackingDict(object):
|
||||||
self.pendingTimeout = pendingTimeout
|
self.pendingTimeout = pendingTimeout
|
||||||
|
|
||||||
def randomKeys(self, count=1):
|
def randomKeys(self, count=1):
|
||||||
if self.len == 0 or (self.pendingLen >= self.maxPending and
|
if self.len == 0 or ((self.pendingLen >= self.maxPending or
|
||||||
self.lastPoll + self.pendingTimeout > time()):
|
self.pendingLen == self.len) and self.lastPoll +
|
||||||
|
self.pendingTimeout > time()):
|
||||||
raise KeyError
|
raise KeyError
|
||||||
# reset if we've requested all
|
# reset if we've requested all
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
|
Reference in New Issue
Block a user