summaryrefslogtreecommitdiff
path: root/sleekxmpp/clientxmpp.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-08-03 17:37:15 -0700
committerLance Stout <lancestout@gmail.com>2011-08-03 17:37:15 -0700
commitd94517d9ca435dbe4d45a35833eaebbdce45b21b (patch)
tree3a8a48b6a9aa17523531b75852ecf1a39825f9af /sleekxmpp/clientxmpp.py
parent0bec040cfed632c40b820eec326f6af262ccde4a (diff)
parente022b2a36c342b6a83d7c7f0a39dfb851cdfd2de (diff)
downloadslixmpp-d94517d9ca435dbe4d45a35833eaebbdce45b21b.tar.gz
slixmpp-d94517d9ca435dbe4d45a35833eaebbdce45b21b.tar.bz2
slixmpp-d94517d9ca435dbe4d45a35833eaebbdce45b21b.tar.xz
slixmpp-d94517d9ca435dbe4d45a35833eaebbdce45b21b.zip
Merge branch 'develop' into stream_features
Diffstat (limited to 'sleekxmpp/clientxmpp.py')
-rw-r--r--sleekxmpp/clientxmpp.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py
index 04c19d3f..95ae108b 100644
--- a/sleekxmpp/clientxmpp.py
+++ b/sleekxmpp/clientxmpp.py
@@ -153,18 +153,23 @@ class ClientXMPP(BaseXMPP):
addresses = {}
intmax = 0
+ topprio = 65535
for answer in answers:
- intmax += answer.priority
- addresses[intmax] = (answer.target.to_text()[:-1],
+ topprio = min(topprio, answer.priority)
+ for answer in answers:
+ if answer.priority == topprio:
+ intmax += answer.weight
+ addresses[intmax] = (answer.target.to_text()[:-1],
answer.port)
+
#python3 returns a generator for dictionary keys
- priorities = [x for x in addresses.keys()]
- priorities.sort()
+ items = [x for x in addresses.keys()]
+ items.sort()
picked = random.randint(0, intmax)
- for priority in priorities:
- if picked <= priority:
- address = addresses[priority]
+ for item in items:
+ if picked <= item:
+ address = addresses[item]
break
if not address: