summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalph Bean <rbean@redhat.com>2017-08-11 17:49:10 +0000
committerRalph Bean <rbean@redhat.com>2017-08-11 17:49:47 +0000
commiteec6e8b8fdd0cf21fdab25aae2d1209d0048448f (patch)
tree7ff1c5694f232db8abc60fdb885b0c4225ee9b30
parent3ba5349bef708a16c61d48fd34fe0a57bec2c016 (diff)
downloadansible-eec6e8b8fdd0cf21fdab25aae2d1209d0048448f.tar.gz
ansible-eec6e8b8fdd0cf21fdab25aae2d1209d0048448f.tar.xz
ansible-eec6e8b8fdd0cf21fdab25aae2d1209d0048448f.zip
More session re-use, for optimization.
-rwxr-xr-xroles/bodhi2/backend/templates/owner-sync-pagure.j210
1 files changed, 4 insertions, 6 deletions
diff --git a/roles/bodhi2/backend/templates/owner-sync-pagure.j2 b/roles/bodhi2/backend/templates/owner-sync-pagure.j2
index 50c2bc863..cc67dddd5 100755
--- a/roles/bodhi2/backend/templates/owner-sync-pagure.j2
+++ b/roles/bodhi2/backend/templates/owner-sync-pagure.j2
@@ -162,7 +162,7 @@ def get_repo_name_and_arches(tag, version):
return repo_name, arches
-def get_pagure_project_name_and_branch(namespace, project_name):
+def get_pagure_project_name_and_branch(session, namespace, project_name):
"""
Gets the branches on a project. This function is used for mapping.
:param namespace: string of the namespace the project is in
@@ -170,7 +170,6 @@ def get_pagure_project_name_and_branch(namespace, project_name):
:return: a tuple containing the string of the project and a list of
branches
"""
- session = retry_session()
project_branches_url = '{0}api/0/{1}/{2}/git/branches'.format(
PAGURE_URL, namespace, project_name)
project_branches_rv = session.get(
@@ -184,7 +183,7 @@ def get_pagure_project_name_and_branch(namespace, project_name):
return project_name, project_branches_rv.json()['branches']
-def get_pagure_project_names_from_page(namespace, page):
+def get_pagure_project_names_from_page(session, namespace, page):
"""
Gets the names of all the Pagure projects on a page. This function is to be
used for mapping.
@@ -194,7 +193,6 @@ def get_pagure_project_names_from_page(namespace, page):
"""
url = urljoin(PAGURE_URL, 'api/0/projects?namespace={0}'.format(namespace))
url = url + '&page={0}&per_page=100&fork=false&short=true'.format(page)
- session = retry_session()
response = session.get(url, verify=VERIFY, timeout=120)
if not bool(response):
print("Failed to talk to %r %r." % (
@@ -230,7 +228,7 @@ def get_pagure_project_branches(namespace):
# Since we are going to multi-thread, we need to make a partial function
# call so that all the function needs is an iterable to run
partial_get_pagure_projects_page = partial(
- get_pagure_project_names_from_page, namespace)
+ get_pagure_project_names_from_page, session, namespace)
project_names_sets = pool.map(partial_get_pagure_projects_page,
range(1, num_pages + 1))
@@ -245,7 +243,7 @@ def get_pagure_project_branches(namespace):
# Since we are going to multi-thread, we need to make a partial function
# call so that all the function needs is an iterable to run
partial_get_pagure_project_name_and_branch = partial(
- get_pagure_project_name_and_branch, namespace)
+ get_pagure_project_name_and_branch, session, namespace)
# Get a list of tuples in the form of (project, [branch...]), then convert
# that to a dictionary
project_names_to_branches = dict(pool.map(