From 4117195b616b10849a01ee371b9bc1bbdbc4ec3c Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sun, 14 Aug 2016 15:03:18 +0200 Subject: [PATCH] Don't freeze when out of known nodes - bitmessage could end up having no known nodes and then it would freeze. Now it shouldn't freeze, however it can still end up without known nodes until a restart in some cases (e.g. when suspending the computer for more then 3 days while BM is running) --- src/class_outgoingSynSender.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/class_outgoingSynSender.py b/src/class_outgoingSynSender.py index ca5ed056..f61129a2 100644 --- a/src/class_outgoingSynSender.py +++ b/src/class_outgoingSynSender.py @@ -37,7 +37,12 @@ class outgoingSynSender(threading.Thread, StoppableThread): else: while not shared.shutdown: shared.knownNodesLock.acquire() - peer, = random.sample(shared.knownNodes[self.streamNumber], 1) + try: + peer, = random.sample(shared.knownNodes[self.streamNumber], 1) + except ValueError: # no known nodes + shared.knownNodesLock.release() + time.sleep(1) + continue priority = (183600 - (time.time() - shared.knownNodes[self.streamNumber][peer])) / 183600 # 2 days and 3 hours shared.knownNodesLock.release() if shared.config.get('bitmessagesettings', 'socksproxytype') != 'none':