Revision dfc8824a

b/lib/jqueue.py
35 35
import time
36 36
import weakref
37 37
import threading
38
import itertools
38 39

  
39 40
try:
40 41
  # pylint: disable-msg=E0611
......
721 722

  
722 723
  """
723 724
  @staticmethod
724
  def _CheckForChanges(job_load_fn, check_fn):
725
  def _CheckForChanges(counter, job_load_fn, check_fn):
726
    if counter.next() > 0:
727
      # If this isn't the first check the job is given some more time to change
728
      # again. This gives better performance for jobs generating many
729
      # changes/messages.
730
      time.sleep(0.1)
731

  
725 732
    job = job_load_fn()
726 733
    if not job:
727 734
      raise errors.JobLost()
......
750 757
    @param timeout: maximum time to wait in seconds
751 758

  
752 759
    """
760
    counter = itertools.count()
753 761
    try:
754 762
      check_fn = _JobChangesChecker(fields, prev_job_info, prev_log_serial)
755 763
      waiter = _JobChangesWaiter(filename)
756 764
      try:
757 765
        return utils.Retry(compat.partial(self._CheckForChanges,
758
                                          job_load_fn, check_fn),
766
                                          counter, job_load_fn, check_fn),
759 767
                           utils.RETRY_REMAINING_TIME, timeout,
760 768
                           wait_fn=waiter.Wait)
761 769
      finally:

Also available in: Unified diff