Don't crash download thread if no connections
This commit is contained in:
parent
41ead2bfb5
commit
a3398d6a17
|
@ -42,7 +42,10 @@ 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)
|
||||||
|
try:
|
||||||
requestChunk = max(int(DownloadThread.maxRequestChunk / len(connections)), 1)
|
requestChunk = max(int(DownloadThread.maxRequestChunk / len(connections)), 1)
|
||||||
|
except ZeroDivisionError:
|
||||||
|
requestChunk = 1
|
||||||
for i in connections:
|
for i in connections:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
timedOut = now - DownloadThread.requestTimeout
|
timedOut = now - DownloadThread.requestTimeout
|
||||||
|
|
Loading…
Reference in New Issue
Block a user