Commit caeffaa0 authored by Iustin Pop's avatar Iustin Pop
Browse files

Partial cherry-pick of 6c881c52 from the 2.1 branch



This cherry-picks the utils.FieldSet.Matches changes and the significant
jqueue.py change. These are stable in the 2.1 branch and therefore make
sense to backport to 2.0 (are basically cleanups).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarOlivier Tharan <olive@google.com>
parent 2b32e20c
......@@ -509,19 +509,14 @@ class _JobQueueWorkerPool(workerpool.WorkerPool):
self.queue = queue
class JobQueue(object):
"""Queue used to manage the jobs.
@cvar _RE_JOB_FILE: regex matching the valid job file names
"""
_RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE)
def _RequireOpenQueue(fn):
def _RequireOpenQueue(fn):
"""Decorator for "public" functions.
This function should be used for all 'public' functions. That is,
functions usually called from other classes.
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.
@warning: Use this decorator only after utils.LockedMethod!
......@@ -537,6 +532,15 @@ class JobQueue(object):
return fn(self, *args, **kwargs)
return wrapper
class JobQueue(object):
"""Queue used to manage the jobs.
@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.
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment