Connect first to best peers based on ping time
This commit is contained in:
parent
36db8a4dc9
commit
2efb6cf4f1
1 changed files with 3 additions and 1 deletions
|
@ -157,7 +157,9 @@ class WorkerManager(object):
|
||||||
if type(peers) is set:
|
if type(peers) is set:
|
||||||
peers = list(peers)
|
peers = list(peers)
|
||||||
|
|
||||||
random.shuffle(peers)
|
# Sort by ping
|
||||||
|
peers.sort(key = lambda peer: peer.connection.last_ping_delay if peer.connection and len(peer.connection.waiting_requests) == 0 else 9999)
|
||||||
|
|
||||||
for peer in peers: # One worker for every peer
|
for peer in peers: # One worker for every peer
|
||||||
if peers and peer not in peers:
|
if peers and peer not in peers:
|
||||||
continue # If peers defined and peer not valid
|
continue # If peers defined and peer not valid
|
||||||
|
|
Loading…
Reference in a new issue