如何并行化 Python Jira search_issues

问题描述 投票:0回答:1

并行化 Python Jira 库中的 search_issues 方法的最快方法是什么?

...

tickets = jira.search_issues(args.query, maxResults=False)

...

在搜索大量 Jira 问题时,上述方法调用可能需要很长时间才能返回。

我事先不知道脚本将在多少个虚拟 CPU 核心上运行。

我找不到使用线程或 aiohttp 的方法,因为 search_issues 方法不是普通的 HTTP GET。

parallel-processing jira jira-rest-api python-jira
1个回答
0
投票

您可以在页面中检索问题,与此类似

    fields = "key,summary,description,customfield_14192"

block_size = 100
block_num = 0
while True:
    start_idx = block_num*block_size
    issue_keys = jira.search_issues(jql, start_idx, block_size, fields=fields)
    if len(issue_keys) == 0:
        # Retrieve issues until there are no more to come
        break
    block_num += 1
    for issue_key in issue_keys:
        # For more than just the issue key, retrieve more info about the issue
        # Use fields='field1,field2' to restrict what is returned for speed
        issue = jira.issue(issue_key)

        log.info('Key: %s' % (issue.key))
        log.info('Summary: %s' % (issue.fields.summary))
© www.soinside.com 2019 - 2024. All rights reserved.