diff --git a/lib/jqueue.py b/lib/jqueue.py index 5113434c85c599ad4d81715ef38dbea4795135c6..8657fed3765a95cae74e458e474b5d2a4f0c268c 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -509,33 +509,37 @@ class _JobQueueWorkerPool(workerpool.WorkerPool): self.queue = queue -class JobQueue(object): - """Queue used to manage the jobs. +def _RequireOpenQueue(fn): + """Decorator for "public" functions. - @cvar _RE_JOB_FILE: regex matching the valid job file names + This function should be used for all 'public' functions. That is, + functions usually called from other classes. Note that this should + be applied only to methods (not plain functions), since it expects + that the decorated function is called with a first argument that has + a '_queue_lock' argument. - """ - _RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE) + @warning: Use this decorator only after utils.LockedMethod! - def _RequireOpenQueue(fn): - """Decorator for "public" functions. + Example:: + @utils.LockedMethod + @_RequireOpenQueue + def Example(self): + pass - This function should be used for all 'public' functions. That is, - functions usually called from other classes. + """ + def wrapper(self, *args, **kwargs): + assert self._queue_lock is not None, "Queue should be open" + return fn(self, *args, **kwargs) + return wrapper - @warning: Use this decorator only after utils.LockedMethod! - Example:: - @utils.LockedMethod - @_RequireOpenQueue - def Example(self): - pass +class JobQueue(object): + """Queue used to manage the jobs. - """ - def wrapper(self, *args, **kwargs): - assert self._queue_lock is not None, "Queue should be open" - return fn(self, *args, **kwargs) - return wrapper + @cvar _RE_JOB_FILE: regex matching the valid job file names + + """ + _RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE) def __init__(self, context): """Constructor for JobQueue. diff --git a/lib/utils.py b/lib/utils.py index bcd8e107bbc44ff94a4bc3dc405b5547719f001d..eb46d49061b715bb8c3e072f3379b3469cbbbfc8 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -2125,12 +2125,12 @@ class FieldSet(object): @type field: str @param field: the string to match - @return: either False or a regular expression match object + @return: either None or a regular expression match object """ for m in itertools.ifilter(None, (val.match(field) for val in self.items)): return m - return False + return None def NonMatching(self, items): """Returns the list of fields not matching the current set