From a3398d6a17e623da780744148be33d4ea7fda02b Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sat, 2 Dec 2017 00:50:58 +0100 Subject: [PATCH] Don't crash download thread if no connections --- src/network/downloadthread.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/network/downloadthread.py b/src/network/downloadthread.py index 0cbdac16..5fe1ee25 100644 --- a/src/network/downloadthread.py +++ b/src/network/downloadthread.py @@ -42,7 +42,10 @@ class DownloadThread(threading.Thread, StoppableThread): # Choose downloading peers randomly connections = BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values() random.shuffle(connections) - requestChunk = max(int(DownloadThread.maxRequestChunk / len(connections)), 1) + try: + requestChunk = max(int(DownloadThread.maxRequestChunk / len(connections)), 1) + except ZeroDivisionError: + requestChunk = 1 for i in connections: now = time.time() timedOut = now - DownloadThread.requestTimeout