Skip to content

Commit

Permalink
Parallelize job posting
Browse files Browse the repository at this point in the history
Speed up posting jobs into openQA and dashboard database

Current implementation post jobs in serial and every post must be
finished before posting another. Jobs itself don't depend on order
or on another jobs so is pretty safe to post more jobs in parallel.
  • Loading branch information
mimi1vx committed Feb 20, 2024
1 parent fbd4bc1 commit d5a3c36
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 d5a3c36

Please sign in to comment.