Revision caeffaa0 lib/jqueue.py

b/lib/jqueue.py
509 509
    self.queue = queue
510 510

  
511 511

  
512
class JobQueue(object):
513
  """Queue used to manage the jobs.
512
def _RequireOpenQueue(fn):
513
  """Decorator for "public" functions.
514 514

  
515
  @cvar _RE_JOB_FILE: regex matching the valid job file names
515
  This function should be used for all 'public' functions. That is,
516
  functions usually called from other classes. Note that this should
517
  be applied only to methods (not plain functions), since it expects
518
  that the decorated function is called with a first argument that has
519
  a '_queue_lock' argument.
516 520

  
517
  """
518
  _RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE)
521
  @warning: Use this decorator only after utils.LockedMethod!
519 522

  
520
  def _RequireOpenQueue(fn):
521
    """Decorator for "public" functions.
523
  Example::
524
    @utils.LockedMethod
525
    @_RequireOpenQueue
526
    def Example(self):
527
      pass
522 528

  
523
    This function should be used for all 'public' functions. That is,
524
    functions usually called from other classes.
529
  """
530
  def wrapper(self, *args, **kwargs):
531
    assert self._queue_lock is not None, "Queue should be open"
532
    return fn(self, *args, **kwargs)
533
  return wrapper
525 534

  
526
    @warning: Use this decorator only after utils.LockedMethod!
527 535

  
528
    Example::
529
      @utils.LockedMethod
530
      @_RequireOpenQueue
531
      def Example(self):
532
        pass
536
class JobQueue(object):
537
  """Queue used to manage the jobs.
533 538

  
534
    """
535
    def wrapper(self, *args, **kwargs):
536
      assert self._queue_lock is not None, "Queue should be open"
537
      return fn(self, *args, **kwargs)
538
    return wrapper
539
  @cvar _RE_JOB_FILE: regex matching the valid job file names
540

  
541
  """
542
  _RE_JOB_FILE = re.compile(r"^job-(%s)$" % constants.JOB_ID_TEMPLATE)
539 543

  
540 544
  def __init__(self, context):
541 545
    """Constructor for JobQueue.

Also available in: Unified diff