Revision 6c881c52 lib/jqueue.py
b/lib/jqueue.py | ||
---|---|---|
540 | 540 |
self.queue = queue |
541 | 541 |
|
542 | 542 |
|
543 |
class JobQueue(object):
|
|
544 |
"""Queue used to manage the jobs.
|
|
543 |
def _RequireOpenQueue(fn):
|
|
544 |
"""Decorator for "public" functions.
|
|
545 | 545 |
|
546 |
@cvar _RE_JOB_FILE: regex matching the valid job file names |
|
546 |
This function should be used for all 'public' functions. That is, |
|
547 |
functions usually called from other classes. Note that this should |
|
548 |
be applied only to methods (not plain functions), since it expects |
|
549 |
that the decorated function is called with a first argument that has |
|
550 |
a '_queue_lock' argument. |
|
547 | 551 |
|
548 |
""" |
|
549 |
_RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE) |
|
552 |
@warning: Use this decorator only after utils.LockedMethod! |
|
550 | 553 |
|
551 |
def _RequireOpenQueue(fn): |
|
552 |
"""Decorator for "public" functions. |
|
554 |
Example:: |
|
555 |
@utils.LockedMethod |
|
556 |
@_RequireOpenQueue |
|
557 |
def Example(self): |
|
558 |
pass |
|
553 | 559 |
|
554 |
This function should be used for all 'public' functions. That is, |
|
555 |
functions usually called from other classes. |
|
560 |
""" |
|
561 |
def wrapper(self, *args, **kwargs): |
|
562 |
assert self._queue_lock is not None, "Queue should be open" |
|
563 |
return fn(self, *args, **kwargs) |
|
564 |
return wrapper |
|
556 | 565 |
|
557 |
@warning: Use this decorator only after utils.LockedMethod! |
|
558 | 566 |
|
559 |
Example:: |
|
560 |
@utils.LockedMethod |
|
561 |
@_RequireOpenQueue |
|
562 |
def Example(self): |
|
563 |
pass |
|
567 |
class JobQueue(object): |
|
568 |
"""Queue used to manage the jobs. |
|
564 | 569 |
|
565 |
""" |
|
566 |
def wrapper(self, *args, **kwargs): |
|
567 |
assert self._queue_lock is not None, "Queue should be open" |
|
568 |
return fn(self, *args, **kwargs) |
|
569 |
return wrapper |
|
570 |
@cvar _RE_JOB_FILE: regex matching the valid job file names |
|
571 |
|
|
572 |
""" |
|
573 |
_RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE) |
|
570 | 574 |
|
571 | 575 |
def __init__(self, context): |
572 | 576 |
"""Constructor for JobQueue. |
Also available in: Unified diff