Distribute downloads more evenly
- also increases expireation of missing objects from 10 minutes to an hour
This commit is contained in:
parent
3b86dfc639
commit
41ead2bfb5
|
@ -13,10 +13,10 @@ from state import missingObjects
|
||||||
|
|
||||||
class DownloadThread(threading.Thread, StoppableThread):
|
class DownloadThread(threading.Thread, StoppableThread):
|
||||||
minPending = 200
|
minPending = 200
|
||||||
requestChunk = 1000
|
maxRequestChunk = 1000
|
||||||
requestTimeout = 60
|
requestTimeout = 60
|
||||||
cleanInterval = 60
|
cleanInterval = 60
|
||||||
requestExpires = 600
|
requestExpires = 3600
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self, name="Downloader")
|
threading.Thread.__init__(self, name="Downloader")
|
||||||
|
@ -42,6 +42,7 @@ class DownloadThread(threading.Thread, StoppableThread):
|
||||||
# Choose downloading peers randomly
|
# Choose downloading peers randomly
|
||||||
connections = BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values()
|
connections = BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values()
|
||||||
random.shuffle(connections)
|
random.shuffle(connections)
|
||||||
|
requestChunk = max(int(DownloadThread.maxRequestChunk / len(connections)), 1)
|
||||||
for i in connections:
|
for i in connections:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
timedOut = now - DownloadThread.requestTimeout
|
timedOut = now - DownloadThread.requestTimeout
|
||||||
|
@ -61,8 +62,8 @@ class DownloadThread(threading.Thread, StoppableThread):
|
||||||
random.shuffle(request)
|
random.shuffle(request)
|
||||||
if not request:
|
if not request:
|
||||||
continue
|
continue
|
||||||
if len(request) > DownloadThread.requestChunk - downloadPending:
|
if len(request) > requestChunk - downloadPending:
|
||||||
request = request[:DownloadThread.requestChunk - downloadPending]
|
request = request[:requestChunk - downloadPending]
|
||||||
# mark them as pending
|
# mark them as pending
|
||||||
for k in request:
|
for k in request:
|
||||||
i.objectsNewToMe[k] = False
|
i.objectsNewToMe[k] = False
|
||||||
|
|
Reference in New Issue
Block a user