Don't crash download thread if no connections

This commit is contained in:
Peter Šurda 2017-12-02 00:50:58 +01:00
parent 41ead2bfb5
commit a3398d6a17
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -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