Skip to content

Commit

Permalink
Merge pull request #165 from mimi1vx/threads
Browse files Browse the repository at this point in the history
Parallelize job posting
  • Loading branch information
mergify[bot] authored Feb 21, 2024
2 parents 4b2a771 + d5a3c36 commit 97005ee
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion openqabot/openqabot.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Copyright SUSE LLC
# SPDX-License-Identifier: MIT
from argparse import Namespace
from concurrent.futures import ThreadPoolExecutor, wait
from logging import getLogger
from os import environ

from openqabot.dashboard import put

from .errors import PostOpenQAError
from .loader.config import get_onearch, load_metadata
from .loader.qem import get_incidents
Expand Down Expand Up @@ -66,7 +68,8 @@ def __call__(self):

else:
log.info("Triggering %d products in openQA", len(post))
for job in post:

def poster(job):
log.info("Triggering %s", str(job))
try:
self.post_openqa(job["openqa"])
Expand All @@ -75,6 +78,9 @@ def __call__(self):
else:
self.post_qem(job["qem"], job["api"])

with ThreadPoolExecutor() as executor:
wait([executor.submit(poster, job) for job in post])

log.info("End of bot run")

return 0

0 comments on commit 97005ee

Please sign in to comment.