2

I have a python function(python 3.6) which executes approximately 140-150 jira search_issue queries and each query approximately takes 7-8 seconds to return the result. So in all this python function takes like 4-5 mins to execute.

Is there a way how to run these queries in parallel inside the python function so that python function's execution time reduces?

I am using 'Jira' package in python.

from jira import JIRA

def jira():
    user = #####
    pwd = #####
    jira_access = JIRA("https://#####.atlassian.net", basic_auth=(user, pwd))
    return jira_access


def jira_count(jira_filter):
    result = jira().search_issues(jira_filter, startAt=0, maxResults=0)
    total_count = len(result)
    return total_count

def final_view():
    query1 = jira_count(jira_filter1)
    query2 = jira_count(jira_filter2)
    query3 = jira_count(jira_filter3)
                   .
                   .
                   .
                   .
                   .
    query150 = jira_count(jira_filter150)
    return query1, query2, query3 ..... query150

1 Answers1

-1

You need to do something like this:

for jira_filter in filters:
   t = threading.Thread(target=jira_count, args=(jira_filter,), daemon=True)
   t.start()
   thr_list.append(t)

for thr in thr_list:
   thr.join()
muyustan
  • 1,555
  • 1
  • 11
  • 23
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 08 '23 at 19:32