From 5d068ec84a22cd4ffa8a613dbb3be004ddd827a1 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Mon, 27 Feb 2017 23:30:31 +0100 Subject: [PATCH] Unnecessary locking - there was a sleep inside a lock --- src/class_outgoingSynSender.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/class_outgoingSynSender.py b/src/class_outgoingSynSender.py index 254caabb..a2f12c4d 100644 --- a/src/class_outgoingSynSender.py +++ b/src/class_outgoingSynSender.py @@ -40,13 +40,13 @@ class outgoingSynSender(threading.Thread, StoppableThread): knownnodes.knownNodes[self.streamNumber][peer] = time.time() else: while not self._stopped: - with knownnodes.knownNodesLock: - try: + try: + with knownnodes.knownNodesLock: peer, = random.sample(knownnodes.knownNodes[self.streamNumber], 1) - except ValueError: # no known nodes - self.stop.wait(1) - continue - priority = (183600 - (time.time() - knownnodes.knownNodes[self.streamNumber][peer])) / 183600 # 2 days and 3 hours + priority = (183600 - (time.time() - knownnodes.knownNodes[self.streamNumber][peer])) / 183600 # 2 days and 3 hours + except ValueError: # no known nodes + self.stop.wait(1) + continue if BMConfigParser().get('bitmessagesettings', 'socksproxytype') != 'none': if peer.host.find(".onion") == -1: priority /= 10 # hidden services have 10x priority over plain net