Revision 188c5e0a

b/lib/jqueue.py
560 560
  def UpdateJob(self, job):
561 561
    return self._UpdateJobUnlocked(job)
562 562

  
563
  # TODO: Figure out locking
564
  #@utils.LockedMethod
565
  def CancelJob(self, job_id):
566
    """Cancels a job.
567

  
568
    @type job_id: string
569
    @param job_id: Job ID of job to be cancelled.
570

  
571
    """
572
    logging.debug("Cancelling job %s", job_id)
573

  
574
    self._lock.acquire()
575
    try:
576
      job = self._LoadJobUnlocked(job_id)
577
    finally:
578
      self._lock.release()
579
    if not job:
580
      logging.debug("Job %s not found", job_id)
581
      return
582

  
583
    if job.GetStatus() not in (constants.JOB_STATUS_QUEUED,):
584
      logging.debug("Job %s is no longer in the queue", job.id)
585
      return
586

  
587
    job.SetCanceled("Job cancelled by request")
588

  
563 589
  @utils.LockedMethod
564 590
  def ArchiveJob(self, job_id):
565 591
    """Archives a job.
......
633 659
  def ArchiveJob(self, job_id):
634 660
    self._jobs.ArchiveJob(job_id)
635 661

  
662
  @utils.LockedMethod
636 663
  def CancelJob(self, job_id):
637
    raise NotImplementedError()
664
    self._jobs.CancelJob(job_id)
638 665

  
639 666
  def _GetJobInfo(self, job, fields):
640 667
    row = []

Also available in: Unified diff