From 7516fbd69025b5e919092cb23e4e827a4b4b0780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 6 Apr 2016 14:22:05 +0200 Subject: [PATCH] [koji-wrapper] Initialize wrappers sequentially MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When multiple threads call `get_profile_module` at the same time, some of them may get an exception from koji. This should prevent the problem. Fixes: #253 Signed-off-by: Lubomír Sedlář --- pungi/wrappers/kojiwrapper.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pungi/wrappers/kojiwrapper.py b/pungi/wrappers/kojiwrapper.py index 9d476ca4..4919f8ec 100644 --- a/pungi/wrappers/kojiwrapper.py +++ b/pungi/wrappers/kojiwrapper.py @@ -19,6 +19,7 @@ import os import pipes import re import time +import threading import koji import rpmUtils.arch @@ -27,12 +28,15 @@ from ConfigParser import ConfigParser class KojiWrapper(object): + lock = threading.Lock() + def __init__(self, profile): self.profile = profile # assumption: profile name equals executable name (it's a symlink -> koji) self.executable = self.profile.replace("_", "-") - self.koji_module = koji.get_profile_module(profile) - self.koji_proxy = koji.ClientSession(self.koji_module.config.server) + with self.lock: + self.koji_module = koji.get_profile_module(profile) + self.koji_proxy = koji.ClientSession(self.koji_module.config.server) def get_runroot_cmd(self, target, arch, command, quiet=False, use_shell=True, channel=None, packages=None, mounts=None, weight=None, task_id=True): cmd = [self.executable, "runroot"]