summaryrefslogtreecommitdiff
path: root/sleekxmpp/clientxmpp.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-07-27 19:35:42 -0700
committerLance Stout <lancestout@gmail.com>2011-07-27 19:35:42 -0700
commitad978700fc891602c826dea03615c396f39364a0 (patch)
tree76315f3d39cd7209c71a164864f5e815d1a27d07 /sleekxmpp/clientxmpp.py
parent48fb7006f75dd03caa23f61cb512f9002fe91b90 (diff)
parente022b2a36c342b6a83d7c7f0a39dfb851cdfd2de (diff)
downloadslixmpp-ad978700fc891602c826dea03615c396f39364a0.tar.gz
slixmpp-ad978700fc891602c826dea03615c396f39364a0.tar.bz2
slixmpp-ad978700fc891602c826dea03615c396f39364a0.tar.xz
slixmpp-ad978700fc891602c826dea03615c396f39364a0.zip
Merge branch 'develop' into roster
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 02d47648..0328e393 100644
--- a/sleekxmpp/clientxmpp.py
+++ b/sleekxmpp/clientxmpp.py
@@ -168,18 +168,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: