Immediately raise ValueError in connectionchooser.chooseConnection()

if have no nodes for given stream.
This commit is contained in:
Dmitri Bogomolov 2020-05-15 18:16:06 +03:00
parent 45508538aa
commit bcc2ca7d33
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -44,7 +44,10 @@ def chooseConnection(stream):
# discovered peers are already filtered by allowed streams
return getDiscoveredPeer()
for _ in range(50):
peer = random.choice(knownnodes.knownNodes[stream].keys())
try:
peer = random.choice(knownnodes.knownNodes[stream].keys())
except IndexError:
break
try:
peer_info = knownnodes.knownNodes[stream][peer]
if peer_info.get('self'):