[koji-wrapper] Initialize wrappers sequentially
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ář <lsedlar@redhat.com>
This commit is contained in:
parent
3e1a6edecc
commit
7516fbd690
@ -19,6 +19,7 @@ import os
|
|||||||
import pipes
|
import pipes
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
import koji
|
import koji
|
||||||
import rpmUtils.arch
|
import rpmUtils.arch
|
||||||
@ -27,10 +28,13 @@ from ConfigParser import ConfigParser
|
|||||||
|
|
||||||
|
|
||||||
class KojiWrapper(object):
|
class KojiWrapper(object):
|
||||||
|
lock = threading.Lock()
|
||||||
|
|
||||||
def __init__(self, profile):
|
def __init__(self, profile):
|
||||||
self.profile = profile
|
self.profile = profile
|
||||||
# assumption: profile name equals executable name (it's a symlink -> koji)
|
# assumption: profile name equals executable name (it's a symlink -> koji)
|
||||||
self.executable = self.profile.replace("_", "-")
|
self.executable = self.profile.replace("_", "-")
|
||||||
|
with self.lock:
|
||||||
self.koji_module = koji.get_profile_module(profile)
|
self.koji_module = koji.get_profile_module(profile)
|
||||||
self.koji_proxy = koji.ClientSession(self.koji_module.config.server)
|
self.koji_proxy = koji.ClientSession(self.koji_module.config.server)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user