Skip to content
Permalink
Browse files

Perform 26 smaller queries instead of 1 to retrieve the entire list o…

…f users

This actually slows down thing a little but at least it no longer runs
into time-out issues.
  • Loading branch information...
pypingou committed May 11, 2016
1 parent 61db84b commit c7802467d733f047cbe1aa289228535005ebc0b1
Showing with 25 additions and 22 deletions.
  1. +25 −22 fedmsg_meta_fedora_infrastructure/fasshim.py
@@ -118,29 +118,32 @@ def make_fas_cache(**config):
)

timeout = socket.getdefaulttimeout()
socket.setdefaulttimeout(600)
try:
log.info("Downloading FAS cache")
request = fasclient.send_request('/user/list',
req_params={'search': '*'},
auth=True)
except fedora.client.ServerError as e:
log.warning("Failed to download fas cache %r" % e)
return {}
finally:
socket.setdefaulttimeout(timeout)

log.info("Caching necessary user data")
for user in request['people']:
nick = user['ircnick']
if nick:
_fas_cache[nick] = user['username']

email = user['email']
if email:
_fas_cache[email] = user['username']
for key in string.ascii_lowercase:
socket.setdefaulttimeout(600)
try:
log.info("Downloading FAS cache for %s*" % key)
request = fasclient.send_request(
'/user/list',
req_params={'search': '%s*' % key},
auth=True)
except fedora.client.ServerError as e:
log.warning("Failed to download fas cache for %s %r" % (key, e))
request = {'people': []}
finally:
socket.setdefaulttimeout(timeout)

log.info("Caching necessary user data")
for user in request['people']:
nick = user['ircnick']
if nick:
_fas_cache[nick] = user['username']

email = user['email']
if email:
_fas_cache[email] = user['username']

del request

del request
del fasclient
del fedora.client.fas2

0 comments on commit c780246

Please sign in to comment.
You can’t perform that action at this time.